You can also return a function like this :
<?php
function ReturnFunc ($num, $num1)
{
if ($num == 1)
{
return function ($num2) use ($num1){return $num1+$num2;} ;
}
else if ($num == 2)
{
return function ($num2) use ($num1){return $num1-$num2;} ;
}
}
function InvokeTheReturnedFunc($num,$num1, $num2)
{
$func = ReturnFunc($num, $num1) ;
echo gettype($func) . '<br />'; return $func($num2) ;
}
echo InvokeTheReturnedFunc(1, 5, 8) . '<br />'; echo InvokeTheReturnedFunc(2, 5, 8) . '<br />'; echo $asdasd ; ?>