a.PHP_EOL; }; $func(); } } $obj=new ClassA(); //带static的匿名函数 class ClassB { public $a=4; function __construct() { $func=static function(){echo $this->a.PHP_EOL;}; //wrong output:Using $this when not in object context $func(); } } $obj2=new ClassB(); ?>