I have 2 or more functions that always takes the same arguments. The argument is the returned value of another function call.
This is the code:
$result = getMyResult();
myFunction1($result);
myFunction2($result);
...
Question
Is there a way to call multiple functions on the same line with the same argument?
An example of what I'm trying to achieve:
myFunction1,myFunction2...(getMyResult());
Demands
- The solution can be procedural or object oriented.
- I don't want to temporary store the returned value of
getMyResult()
in a variable. - I only want to call
getMyResult()
once. - I don't want to wrap the function calls in a helper function *
* like this.
function myHelperFunction($result) {
myFunction1($result);
myFunction2($result);
...
}
If myHelperFunction()
is the closest solution, then I'm happy to hear about it.