- use them anywhere and everywhere
<?php
echo myFunc(1);
?>;
Functions can be nested:
<?php
$r = mysql_fetch_assoc(getData($sql));
echo ;
?>;
functions can return values:
<?php
function myFunc($arg1) {
if($arg1 >= 5) { return true; }
else { return false; }
}
function myFunc($\arg1) {
if($arg1==5) { = "Equal to 5"; }
else { $val = "Not equal to 5"; }
return $val;
}
?>
You can set default values for arguments:
<?php
function myFunc($arg1="defaultValue", $arg2="defaultValue2") {
//if the function is called like this...
//myFunc(), then it will use defaultValue and defaultValue2 as
//$arg1 and $arg2 respectively
}
?>;
NEXT
PREVIOUS
Master Index