3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Example { protected $foo = 'bar'; public function test() { $closure = function() use ($this->foo) { return $this->foo; }; return $closure(); } } $e = new Example; $c = $e->test(); echo $c;
Output for 5.3.0 - 5.3.16, 5.4.0 - 5.4.6
Fatal error: Cannot use $this as lexical variable in /in/m53I9 on line 6
Process exited with code 255.

preferences:
215.34 ms | 1395 KiB | 31 Q