3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $bar; public function getClosure($bar = 'foo') { $this->bar = $bar; return function () use ($this->bar => $bar) { return $bar; }; } } $foo = new Foo; $closure = $foo->getClosure(); var_dump($closure());
Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.28
Fatal error: Cannot use $this as lexical variable in /in/ZorRb on line 9
Process exited with code 255.

preferences:
184.92 ms | 1395 KiB | 65 Q