3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function test() { //It's crucial to construct it in the same line return new class{ static $foo = '-'; }; } $x = test(); $x::$foo = 'x'; $y = test(); $y::$foo = 'y'; var_dump($x::$foo, $y::$foo, ($x === $y), (get_class($x) === get_class($y)));
Output for hhvm-3.18.5 - 3.22.0, 7.1.0 - 7.3.0alpha1
string(1) "y" string(1) "y" bool(false) bool(true)
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/Ms2bH on line 6
Process exited with code 255.