NameSilo

PHP "function"

Spaceship Spaceship
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
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
.US domains.US domains
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
•••
Thank you very much! :]
NP$ Donated and Rep added!
 
0
•••
Appraise.net

We're social

Domain Recover
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back