3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CErrorException extends Exception {} function handleError($level, $message, $file, $line){ var_dump(error_reporting()); if( error_reporting() != 0){ throw new CErrorException($message, $level); } } function handleException(Exception $exception){ var_dump('Exception handled at global level'); } set_error_handler('handleError'); set_exception_handler('handleException'); try { require_once('non\existent\file'); //Will generate an error and cause an exception to be thrown. } catch (Exception $e) { var_dump("let's deal with the exception"); }
Output for 8.0.3 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
int(-1) string(29) "let's deal with the exception"
Output for 8.0.13
int(32767) string(29) "let's deal with the exception"
Output for 8.0.0 - 8.0.2
int(-1) Fatal error: Uncaught TypeError: handleException(): Argument #1 ($exception) must be of type Exception, Error given in /in/ljehL:11 Stack trace: #0 [internal function]: handleException(Object(Error)) #1 {main} thrown in /in/ljehL on line 11
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.7, 7.4.33
int(-1) Warning: Uncaught CErrorException: require_once(non\existent\file): failed to open stream: No such file or directory in /in/ljehL:7 Stack trace: #0 /in/ljehL(20): handleError(2, 'require_once(no...', '/in/ljehL', 20, Array) #1 /in/ljehL(20): require_once() #2 {main} thrown in /in/ljehL on line 7 Fatal error: main(): Failed opening required 'non\existent\file' (include_path='.:') in /in/ljehL on line 20
Process exited with code 255.
Output for 7.1.26 - 7.1.33, 7.2.17 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.32
int(-1) Warning: Uncaught CErrorException: require_once(): open_basedir restriction in effect. File(non\existent\file) is not within the allowed path(s): (/tmp:/in:/etc) in /in/ljehL:7 Stack trace: #0 /in/ljehL(20): handleError(2, 'require_once():...', '/in/ljehL', 20, Array) #1 /in/ljehL(20): require_once() #2 {main} thrown in /in/ljehL on line 7 Fatal error: main(): Failed opening required 'non\existent\file' (include_path='.:') in /in/ljehL on line 20
Process exited with code 255.
Output for 7.3.32 - 7.3.33
int(22519) Warning: Uncaught CErrorException: require_once(non\existent\file): failed to open stream: No such file or directory in /in/ljehL:7 Stack trace: #0 /in/ljehL(20): handleError(2, 'require_once(no...', '/in/ljehL', 20, Array) #1 /in/ljehL(20): require_once() #2 {main} thrown in /in/ljehL on line 7 Fatal error: main(): Failed opening required 'non\existent\file' (include_path='.:') in /in/ljehL on line 20
Process exited with code 255.
Output for 7.1.20, 7.2.6
int(-1) Warning: Uncaught CErrorException: require_once(): open_basedir restriction in effect. File(non\existent\file) is not within the allowed path(s): (/tmp:/in) in /in/ljehL:7 Stack trace: #0 /in/ljehL(20): handleError(2, 'require_once():...', '/in/ljehL', 20, Array) #1 /in/ljehL(20): require_once() #2 {main} thrown in /in/ljehL on line 7 Fatal error: main(): Failed opening required 'non\existent\file' (include_path='.:') in /in/ljehL on line 20
Process exited with code 255.
Output for 5.3.18 - 5.3.29, 5.4.8 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
int(-1) Warning: Uncaught exception 'CErrorException' with message 'require_once(non\existent\file): failed to open stream: No such file or directory' in /in/ljehL:7 Stack trace: #0 /in/ljehL(20): handleError(2, 'require_once(no...', '/in/ljehL', 20, Array) #1 /in/ljehL(20): require_once() #2 {main} thrown in /in/ljehL on line 7 Fatal error: main(): Failed opening required 'non\existent\file' (include_path='.:') in /in/ljehL on line 20
Process exited with code 255.
Output for 5.3.3 - 5.3.17, 5.4.0 - 5.4.7
int(-1) Fatal error: main(): Failed opening required 'non\existent\file' (include_path='.:') in /in/ljehL on line 20
Process exited with code 255.
Output for 5.3.0 - 5.3.2
int(-1) Fatal error: main(): Failed opening required 'non\existent\file' (include_path='.:') in /in/ljehL on line 0
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
int(-1) Fatal error: main(): Failed opening required 'non\existent\file' (include_path='.:') in /in/ljehL on line 23
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_NEW in /in/ljehL on line 7
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_NEW in /in/ljehL on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/ljehL on line 7
Process exited with code 255.

preferences:
231.22 ms | 401 KiB | 341 Q