3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class ExceptionHandler { public static function printException(Exception $e) { print 'Uncaught '.get_class($e).', code: ' . $e->getCode() . "<br />Message: " . htmlentities($e->getMessage())."\n"; } public static function handleException(Exception $e) { self::printException($e); } } set_exception_handler(array("ExceptionHandler", "handleException")); throw new Exception("Catch me twice", 2); ?>
based on mWMQi
Output for 5.0.1 - 7.2.0
Uncaught Exception, code: 2<br />Message: Catch me twice
Output for 5.0.0
Fatal error: Uncaught exception 'Exception' with message 'Catch me twice' in /in/9MCcP:16 Stack trace: #0 {main} thrown in /in/9MCcP on line 16
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/9MCcP on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/9MCcP on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/9MCcP on line 3
Process exited with code 255.