NameSilo

PHP "function"

SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Watch

SiKing

Registered MemberEstablished Member
Impact
6
Hey, can anybody explain to me the basics of "function" and "case" which are used in PHP. A link to a tutorial would be cool also. Thanks
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Hello,

Sure first lets start with case.

CASE is a function used by the function switch. Switch is commonly used when having alot of if and else commands insted of if and else. It does the same thing.
IF are more faster when doing small if and else command but time consuming when you have around 20 of them. So PHP made a function which allowed you to do this more cleanly and faster processing.
Switch tells the computer to check the variable for cases. Or if non found it does what default is set to.
Example:
PHP:
$happy = 'HELLO';
switch $happy {
case 'Hi':
// Do something
break;
case 'HELLO':
// Do something
break;
}
(As shown here http://ca.php.net/manual/en/control-structures.switch.php )
As for a tutorial you can find one at that php link above.

Now for functions.
Function pretty much sets a function. Tells the browser to set a class function so when called it processed it and returns a value (Wether true or false)
Example
PHP:
function bob() {
print 'hello';
}

bob();
// Will print hello
?>

You can also transfer variables through a function like this
PHP:
function bob($bob) {
print '$bob';
}

bob('hello');
// Will print hello
?>
This will call the function bob. Passing the value of hello to the variable bob. It will than print hello.


Thanks,
iNod
 
0
Close
Thank you very much! :]
NP$ Donated and Rep added!
 
0
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

A browser tab with a favicon next to the page title
Search members
You can now search for members by name, company, location and more. Open the search at the top of any page and choose Members. You will...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back