Is it in PHP possible to pass a executed function as function's parameter, so that the result of the function will be hand over but not a callback function object?
Without touching the scope function (no eval or extra magic execution).
Let's say, the parameter I want to give the function is not clear. So there must be a decision for that before given to the function.
Currently this always lookes like this:
$tmp = ($something == $bla)?42:7;
myFunction($tmp);
For such a short decision it is not so problematic. But sometimes there are more then two possibilities. So a if-elseif is needed, or a switch-case.
But it would be so much cleaner to just put somthing like this:
myFunction(function(){
if(...){ return 42; }
elseif(...){ return 7; }
elseif(...){ return 5; }
elseif(...){ return 12; }
else{ return 1; }
});
So without saving it first to a variable.
Just for cleaner code, less $tmp or $trash variables.