3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class X{ function test(){ return new class(){ private function __construct(){} }; } } $x = new X; var_dump($c = $x->test()); $class = get_class($c); new $class;
based on 6MDKQ
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to private class@anonymous::__construct() from context 'X' in /in/d6gQG:6 Stack trace: #0 /in/d6gQG(14): X->test() #1 {main} thrown in /in/d6gQG on line 6
Process exited with code 255.
Output for 5.4.0 - 5.6.28
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/d6gQG on line 6
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected T_CLASS in /in/d6gQG on line 6
Process exited with code 255.