Why can I not use $this as a lexical variable in PHP 5.5.4?

后端 未结 8 1619
再見小時候
再見小時候 2020-12-04 01:12
$ php --version
PHP 5.5.4 (cli) (built: Sep 19 2013 17:10:06) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
         


        
8条回答
  •  既然无缘
    2020-12-04 02:10

    In PHP 5.3 if you are using a Closure inside of a class, the Closure will not have access to $this.

    In PHP 5.4, support has been added for the usage of $this in Closures.

提交回复
热议问题