This question already has an answer here:
$function = function($parameter) use ($variable)
{
//Do some stuff
$function($something); //When I do this i get variable undefined '$function'
}
How can I call the function?
I've already tried to call the parent or redefine the variable but i'd like a more compact solution than just redefining a whole new function and using that.
</div>
The general trick here is to use ()
the Closure holding variable by reference:
$function = function($parameter) use ($variable, &$function) {
//Do some stuff
$function($something);
}