Re: Re: Closures and __FUNCTION__

From: Date: Mon, 13 Apr 2009 08:17:53 +0000
Subject: Re: Re: Closures and __FUNCTION__
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-43672@lists.php.net to get a copy of this message
> First, we define $foo and load it with NULL so that it is available for > referencing. It turns out loading $foo is superfluous; I can get away with just: $foo = function($foo) use (&$foo) { $foo(); } > 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. That much is clear; but why $foo is all of the sudden bound within the closure when I use by reference (&$foo) as opposed to use by value ($foo) is mysterious.

« previous php.internals (#43672) next »