In the code below, is there a single way for $bar()
to know that it was called being an argument of foo()
:
// This function belongs to a 3er party library I don't have access to
function foo( $baz ){
// code here
}
// This is my function
$bar = function(){
$argumentOf = ???; // some dark magic here
echo $argumentOf; // print "foo"
// more code goes here
return "something interesting";
};
echo foo( $bar() );
I know that I could make $bar()
to accept an argument and then call it like this:
foo( $bar( "foo" ) );
It is possible without explicitly passing the name of the function?
I tried debug_backtrace to no avail.