3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ExceptionHandler { public function __construct() { set_exception_handler($this); } public function __invoke(Exception $e) { echo $exception->getMessage(); } } function error() { throw new Exception('Error'); } set_error_handler('error'); new ExceptionHandler; throw new Exception("Test");
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Exception: Error in /in/bcnUk:18 Stack trace: #0 /in/bcnUk(12): error(2, 'Undefined varia...', '/in/bcnUk', 12) #1 [internal function]: ExceptionHandler->__invoke(Object(Exception)) #2 {main} thrown in /in/bcnUk on line 18
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.6 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught Exception: Error in /in/bcnUk:18 Stack trace: #0 /in/bcnUk(12): error(8, 'Undefined varia...', '/in/bcnUk', 12, Array) #1 [internal function]: ExceptionHandler->__invoke(Object(Exception)) #2 {main} thrown in /in/bcnUk on line 18
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Fatal error: Uncaught exception 'Exception' with message 'Error' in /in/bcnUk:18 Stack trace: #0 /in/bcnUk(12): error(8, 'Undefined varia...', '/in/bcnUk', 12, Array) #1 [internal function]: ExceptionHandler->__invoke(Object(Exception)) #2 {main} thrown in /in/bcnUk on line 18
Process exited with code 255.
Output for 5.3.18 - 5.3.29, 5.4.8 - 5.4.45
Warning: Uncaught exception 'Exception' with message 'Error' in /in/bcnUk:18 Stack trace: #0 /in/bcnUk(12): error(8, 'Undefined varia...', '/in/bcnUk', 12, Array) #1 [internal function]: ExceptionHandler->__invoke(Object(Exception)) #2 {main} thrown in /in/bcnUk on line 18 Fatal error: Call to a member function getMessage() on a non-object in /in/bcnUk on line 12
Process exited with code 255.
Output for 5.3.3 - 5.3.17, 5.4.0 - 5.4.7
Fatal error: Call to a member function getMessage() on a non-object in /in/bcnUk on line 12
Process exited with code 255.
Output for 5.3.0 - 5.3.2
Fatal error: Call to a member function getMessage() on a non-object in /in/bcnUk on line 0
Process exited with code 255.
Output for 5.2.0 - 5.2.17
Fatal error: Uncaught exception 'Exception' with message 'Error' in /in/bcnUk:18 Stack trace: #0 [internal function]: error(4096, 'Object of class...', '/in/bcnUk', 7, Array) #1 /in/bcnUk(7): set_exception_handler(Object(ExceptionHandler)) #2 /in/bcnUk(22): ExceptionHandler->__construct() #3 {main} thrown in /in/bcnUk on line 18
Process exited with code 255.
Output for 5.0.5, 5.1.0 - 5.1.6
Fatal error: Uncaught exception 'Exception' with message 'Error' in /in/bcnUk:18 Stack trace: #0 [internal function]: error(2, 'set_exception_h...', '/in/bcnUk', 7, Array) #1 /in/bcnUk(7): set_exception_handler(Object(ExceptionHandler)) #2 /in/bcnUk(22): ExceptionHandler->__construct() #3 {main} thrown in /in/bcnUk on line 18
Process exited with code 255.
Output for 5.0.3 - 5.0.4
Fatal error: Uncaught exception 'Exception' with message 'Error' in /in/bcnUk:18 Stack trace: #0 /in/bcnUk(18): error() #1 /in/bcnUk(7): error(2, 'set_exception_h...', '/in/bcnUk', 7, Array) #2 /in/bcnUk(7): set_exception_handler(Object(ExceptionHandler)) #3 /in/bcnUk(22): ExceptionHandler->__construct() #4 {main} thrown in /in/bcnUk on line 18
Process exited with code 255.
Output for 5.0.0 - 5.0.2
Fatal error: Uncaught exception 'Exception' with message 'Error' in /in/bcnUk:18 Stack trace: #0 /in/bcnUk(7): error(2, 'set_exception_h...', '/in/bcnUk', 7, Array) #1 /in/bcnUk(7): set_exception_handler(Object(ExceptionHandler)) #2 /in/bcnUk(22): ExceptionHandler->__construct() #3 {main} thrown in /in/bcnUk on line 18
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/bcnUk on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/bcnUk on line 5
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/bcnUk on line 5
Process exited with code 255.

preferences:
279.33 ms | 401 KiB | 344 Q