You have to 'return' the variable in your function, which basically just means that when that function is called, it will hold that result.
function add( $x, $y )
{
$result = $x + $y;
return $result;
}
print add( 5, 12 );
Rather than printing, you can create a new variable (lets call it $foo) by saying
$foo = add( 5, 12);
You can also rewrite the function above like this:
function add( $x, $y )
{
return $x + $y;
}
since there is no point in creating a local variable that you just need to return.