Re: Closure and $this

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 12 Jan 2011 20:02:11 -0800 (PST)
Raymond Irving <xwisdom@xxxxxxxxx> wrote:

> Hello,
> Does anyone know if closures will ever support the $this keyword? 
> I think it would be very useful when working with objects.
> 
> Best regards__RaymondDo more with less - http://raxanpdi.com
> 

Probably not, and my understanding of why comes from this line from the
docs (http://www.php.net/manual/en/functions.anonymous.php):

"Anonymous functions are currently implemented using the Closure class."

So, in other words, your closure does not belong to the class you
declare it in, but the Closure class.

 Thus, if it supported the $this variable, it would refer not to the
 class you want, but instead to the Closure class.

Just my understanding.  If it's not right, someone point it out.

-- 
Greg Bair
PHP Developer

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux