3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $foo = new class { public function __set(string $name, $value) { throw new \Exception; } }; $foo->destructListener = new class { public function __destruct() {echo "bye"; debug_print_backtrace(); } }; unset($foo);
based on KT1TX
Output for 7.0.0 - 7.3.0
Fatal error: Uncaught Exception in /in/oa121:4 Stack trace: #0 /in/oa121(7): class@anonymous->__set('destructListene...', Object(class@anonymous)) #1 {main} thrown in /in/oa121 on line 4
Process exited with code 255.
Output for 5.5.0 - 5.6.38
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/oa121 on line 3
Process exited with code 255.