I played with anonymous functions in PHP and realized that they don't seem to reach variables outside of them. Is there a way around this problem?
Example:
$variable = "nothing"; functionName(someArgument, function() { $variable = "something"; }); echo $variable;
It will display: "nothing." Is there a way for an anonymous function to access the $ variable?
function variables php global-variables anonymous
einord Jul 10 '12 at 19:30 2012-07-10 19:30
source share