I'll start from the begining. To create a function you would use the following format
function <function name> (<arguments if any>)
{
//function code
}
an example for that would be function that takes in 2 numbers, adds them, and returns an answer
function add_num($num1, $num2)
{
$answer = ($num1+$num2);
return $answer;
}
This function will take in 2 numbers (num1,num2) add them together and store the answer in a variable named $answer. The function will than return (eg. make the variable avail.) to the actual code by the return statement. To call this function you would do
add_num(x,y);
Here's a complete example:
//begin here
function add_num($num1, $num2)
{
$answer = ($num1+$num2);
return $answer;
}
$ans = add_num(4,6); //assign the return value to $ans
print "$ans"; //print the value of ans. In this case 10 since 4+6 is 10.