Can anybody explain how user defined functions works?
example:
PHP Code:function foo ($arg_1, $arg_2, ..., $arg_n //what are these values and how they are defined?)
{
echo "Example function.\n";
return $retval; //what is returned here?
}
| SitePoint Sponsor |
Can anybody explain how user defined functions works?
example:
PHP Code:function foo ($arg_1, $arg_2, ..., $arg_n //what are these values and how they are defined?)
{
echo "Example function.\n";
return $retval; //what is returned here?
}
my mobile portal
ghiris.ro
User defined functions work just like the all other php functions.
$arg_1, $arg_2, ..., $arg_n are function arguments, the values that you pass to the function to work with. Ex.:
In the example, you see that the function is defined with two arguments which it use to add and return the result. This explains "return" as well.PHP Code:function sum($a, $b){
return $a+$b;
}
echo sum(2,3); //outputs 5
Hope this helps.
Saul
Bookmarks