Well, it's a rather simple bit of logic.

First, we define $foo and load it with NULL so that it is available for
referencing. Next, in terms of program logic, we create a closure with a
lexical ('use') variable of a reference to $foo, which is then assigned
to $foo. Thus, the reference to $foo in the closure declaration now
points to the closure itself.

Recursion is always complicated :P

Thanks,
Justin Martin

Peter Danenberg wrote:
> Quoth Justin Martin on Pungenday, the 30th of Discord:
>> Apparently it works as such:
>>
>> $foo = NULL;
>> $foo = function($foo) use (&$foo) {
>>      ...
>> }
>>
>> Still rather hackish, but better than globals I suppose?
> 
> Heh; amazing. I'm not going to pretend to comprehend this hack; but
> I'll use it, nonetheless.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to