3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php set_time_limit( 1 ); function f() { $foo = null; try { echo "...\n"; class Foo implements Throwable {} } catch ( Error $e ) { echo "----\nCaught error: $e\n----\n"; } } function f1() { f(); } set_exception_handler(function() { echo "----\nException handler: "; var_dump(func_get_args()); echo "----\n"; return false;}); set_error_handler(function() { echo "----\nError handler: "; var_dump(func_get_args()); echo "----\n"; return false;}, 0xffffffff); register_shutdown_function(function() { echo "----\nShutdown function: "; var_dump(error_get_last()); echo "----\n"; }); f1();
Output for 7.1.0 - 7.2.6
... Fatal error: Class Foo cannot implement interface Throwable, extend Exception or Error instead in /in/tfpvM on line 9 ---- Shutdown function: array(4) { ["type"]=> int(1) ["message"]=> string(81) "Class Foo cannot implement interface Throwable, extend Exception or Error instead" ["file"]=> string(9) "/in/tfpvM" ["line"]=> int(9) } ----
Process exited with code 255.
Output for hhvm-3.22.0
... ---- Caught error: Error: Class Foo contains abstract method (getMessage) and must therefore be declared abstract or implement the remaining methods in /in/tfpvM:-1 Stack trace: #0 /in/tfpvM(-1): f() #1 /in/tfpvM(-1): f1() #2 {main} ---- ---- Shutdown function: array(4) { ["type"]=> int(1) ["message"]=> string(122) "Class Foo contains abstract method (getMessage) and must therefore be declared abstract or implement the remaining methods" ["file"]=> string(9) "/in/tfpvM" ["line"]=> int(-1) } ----
Output for hhvm-3.18.5 - 3.21.3
... ---- Caught error: Error: Class Foo contains abstract method (getMessage) and must therefore be declared abstract or implement the remaining methods in /in/tfpvM:9 Stack trace: #0 /in/tfpvM(16): f() #1 /in/tfpvM(22): f1() #2 {main} ---- ---- Shutdown function: array(4) { ["type"]=> int(1) ["message"]=> string(122) "Class Foo contains abstract method (getMessage) and must therefore be declared abstract or implement the remaining methods" ["file"]=> string(9) "/in/tfpvM" ["line"]=> int(9) } ----
Output for 5.6.0 - 5.6.30
... Fatal error: Interface 'Throwable' not found in /in/tfpvM on line 9 ---- Shutdown function: array(4) { ["type"]=> int(1) ["message"]=> string(31) "Interface 'Throwable' not found" ["file"]=> string(9) "/in/tfpvM" ["line"]=> int(9) } ----
Process exited with code 255.