3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $value = 1; public function getClosure() { return function() use($this) { return $this->value; }; } } $a = new A; $fn = $a->getClosure(); echo $fn(); // 1
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.40, 5.5.24, 5.6.8
Fatal error: Cannot use $this as lexical variable in /in/YeAJi on line 6
Process exited with code 255.

preferences:
185.66 ms | 1395 KiB | 79 Q