3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { public function bar() { $foo = 'foo'; $bar = new class() use ($foo) { public function classMethod() { var_dump($foo); } }; $bar->classMethod(); } } $foo = new Foo(); $foo->bar();
based on cv0S2
Output for 7.0.0
Parse error: syntax error, unexpected 'use' (T_USE), expecting '{' in /in/4P24e on line 9
Process exited with code 255.
Output for 5.4.10 - 5.6.16
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/4P24e on line 9
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected T_CLASS in /in/4P24e on line 9
Process exited with code 255.