3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $obj1 = new \stdClass; // Instantiate stdClass object $obj2 = new class{}; // Instantiate anonymous class $obj3 = (object)[]; // Cast empty array to object var_dump($obj1); // object(stdClass)#1 (0) {} var_dump($obj2); // object(class@anonymous)#2 (0) {} var_dump($obj3); // object(stdClass)#3 (0) {}
based on gJFJp
Output for 7.1.0 - 7.3.0beta1
object(stdClass)#1 (0) { } object(class@anonymous)#2 (0) { } object(stdClass)#3 (0) { }
Output for hhvm-3.21.3 - 3.22.0
object(stdClass)#1 (0) { } object(class@anonymous$;4)#2 (0) { } object(stdClass)#3 (0) { }
Output for hhvm-3.18.5
object(stdClass)#1 (0) { } object(class@anonymous$;2)#2 (0) { } object(stdClass)#3 (0) { }
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/X5UPg on line 5
Process exited with code 255.