3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { private $a = 42; } $closure = function() { var_dump($this->a); }; $closure->call(new Foo); $closure->__invoke(new Foo);
based on mruUY
Output for 7.0.0 - 7.2.0
int(42) Fatal error: Uncaught Error: Using $this when not in object context in /in/UopfY:4 Stack trace: #0 /in/UopfY(8): {closure}(Object(Foo)) #1 /in/UopfY(8): Closure->__invoke(Object(Foo)) #2 {main} thrown in /in/UopfY on line 4
Process exited with code 255.
Output for 5.3.19 - 5.6.28
Fatal error: Call to undefined method Closure::call() in /in/UopfY on line 6
Process exited with code 255.