3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function demo(callable $callback) { $callback(); } class A { function great($name) { return 'Hello ' . $name; } } demo(new class ("Monde") extends A { public function __invoke() { echo $this->greate('world'); } });
based on KdbsQ
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to undefined method class@anonymous::greate() in /in/PoMh9:16 Stack trace: #0 /in/PoMh9(4): class@anonymous->__invoke() #1 /in/PoMh9(14): demo(Object(class@anonymous)) #2 {main} thrown in /in/PoMh9 on line 16
Process exited with code 255.
Output for 5.4.2 - 5.6.28
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/PoMh9 on line 14
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected T_CLASS in /in/PoMh9 on line 14
Process exited with code 255.