3v4l.org

run code in 300+ PHP versions simultaneously
<?php $errorTypes = [ E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => 'Parse Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_USER_DEPRECATED => 'Deprecated', E_STRICT => 'Strict Standards', E_RECOVERABLE_ERROR => 'Catchable Fatal' ]; $fatalErrorTypes = [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR]; function log_error($num, $str, $file, $line, $context = null, $exit = true) { global $errorTypes; global $fatalErrorTypes; $bFatal = true; if (isset($errorTypes[$num])) { $errType = $errorTypes[$num]; $bFatal = in_array($num, $fatalErrorTypes); } else { $errType = "Unknown error #$num"; } // would normally record stuff here echo "PHP $errType [$file:$line]: $str\n"; if ($bFatal && $exit) { die; } } function check_for_fatal() { global $fatalErrorTypes; $error = error_get_last(); if (in_array($error['type'], $fatalErrorTypes)) { log_error($error["type"], $error["message"], $error["file"], $error["line"], null, false); $output = '{"errors":[{"code":"internal_server_error"}]}'; // would normally record stuff here echo $output; } } function log_exception(\Exception $e) { echo get_class($e) . ': ' . $e->getMessage(); } register_shutdown_function('check_for_fatal'); set_error_handler('log_error'); set_exception_handler('log_exception'); $broken = null; echo $broken->length();
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.4, 8.3.6
Fatal error: Uncaught TypeError: log_exception(): Argument #1 ($e) must be of type Exception, Error given in /in/koMt3:56 Stack trace: #0 [internal function]: log_exception(Object(Error)) #1 {main} thrown in /in/koMt3 on line 56 PHP Error [/in/koMt3:56]: Uncaught TypeError: log_exception(): Argument #1 ($e) must be of type Exception, Error given in /in/koMt3:56 Stack trace: #0 [internal function]: log_exception(Object(Error)) #1 {main} thrown {"errors":[{"code":"internal_server_error"}]}
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Fatal error: Uncaught TypeError: log_exception(): Argument #1 ($e) must be of type Exception, Error given in /in/koMt3:56 Stack trace: #0 [internal function]: log_exception(Object(Error)) #1 {main} thrown in /in/koMt3 on line 56 PHP Error [/in/koMt3:56]: Uncaught TypeError: log_exception(): Argument #1 ($e) must be of type Exception, Error given in /in/koMt3:56 Stack trace: #0 [internal function]: log_exception(Object(Error)) #1 {main} thrown {"errors":[{"code":"internal_server_error"}]}
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: Argument 1 passed to log_exception() must be an instance of Exception, instance of Error given in /in/koMt3:56 Stack trace: #0 [internal function]: log_exception(Object(Error)) #1 {main} thrown in /in/koMt3 on line 56 PHP Error [/in/koMt3:56]: Uncaught TypeError: Argument 1 passed to log_exception() must be an instance of Exception, instance of Error given in /in/koMt3:56 Stack trace: #0 [internal function]: log_exception(Object(Error)) #1 {main} thrown {"errors":[{"code":"internal_server_error"}]}
Process exited with code 255.
Output for 5.6.0 - 5.6.25
Fatal error: Call to a member function length() on null in /in/koMt3 on line 65 PHP Error [/in/koMt3:65]: Call to a member function length() on null {"errors":[{"code":"internal_server_error"}]}
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38
Fatal error: Call to a member function length() on a non-object in /in/koMt3 on line 65 PHP Error [/in/koMt3:65]: Call to a member function length() on a non-object {"errors":[{"code":"internal_server_error"}]}
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/koMt3 on line 3
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, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/koMt3 on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/koMt3 on line 3
Process exited with code 255.

preferences:
275.11 ms | 401 KiB | 353 Q