3v4l.org

run code in 300+ PHP versions simultaneously
<?php $success=false; if (true) { set_error_handler(function($a, $b, $c, $d) { var_dump('error_handler', $a, $b, $c, $d); throw new ErrorException($a, $b, $c, $d); }); register_shutdown_function(function(){ if ($GLOBALS['success']){return;} var_dump('shutdown_function', error_get_last()); }); } $var = 1; try { // $var->method(); // Throws an Error object in PHP 7. $buf.='nyanpasu'; /* } catch (Error $e) { // Handle error var_dump('error', $e); */ } catch (Exception $e) { // Handle error var_dump('exception', $e); } $success=true; ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
string(13) "error_handler" int(2) string(23) "Undefined variable $buf" string(9) "/in/OtM0R" int(19) Fatal error: Uncaught TypeError: ErrorException::__construct(): Argument #2 ($code) must be of type int, string given in /in/OtM0R:6 Stack trace: #0 /in/OtM0R(6): ErrorException->__construct('2', 'Undefined varia...', '/in/OtM0R', 19) #1 /in/OtM0R(19): {closure}(2, 'Undefined varia...', '/in/OtM0R', 19) #2 {main} thrown in /in/OtM0R on line 6 string(17) "shutdown_function" array(4) { ["type"]=> int(1) ["message"]=> string(310) "Uncaught TypeError: ErrorException::__construct(): Argument #2 ($code) must be of type int, string given in /in/OtM0R:6 Stack trace: #0 /in/OtM0R(6): ErrorException->__construct('2', 'Undefined varia...', '/in/OtM0R', 19) #1 /in/OtM0R(19): {closure}(2, 'Undefined varia...', '/in/OtM0R', 19) #2 {main} thrown" ["file"]=> string(9) "/in/OtM0R" ["line"]=> int(6) }
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
string(13) "error_handler" int(8) string(23) "Undefined variable: buf" string(9) "/in/OtM0R" int(19) Fatal error: Uncaught Error: Wrong parameters for ErrorException([string $message [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Throwable $previous = NULL]]]]]]) in /in/OtM0R:6 Stack trace: #0 /in/OtM0R(6): ErrorException->__construct('8', 'Undefined varia...', '/in/OtM0R', 19) #1 /in/OtM0R(19): {closure}(8, 'Undefined varia...', '/in/OtM0R', 19, Array) #2 {main} thrown in /in/OtM0R on line 6 string(17) "shutdown_function" array(4) { ["type"]=> int(1) ["message"]=> string(387) "Uncaught Error: Wrong parameters for ErrorException([string $message [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Throwable $previous = NULL]]]]]]) in /in/OtM0R:6 Stack trace: #0 /in/OtM0R(6): ErrorException->__construct('8', 'Undefined varia...', '/in/OtM0R', 19) #1 /in/OtM0R(19): {closure}(8, 'Undefined varia...', '/in/OtM0R', 19, Array) #2 {main} thrown" ["file"]=> string(9) "/in/OtM0R" ["line"]=> int(6) }
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
string(13) "error_handler" int(8) string(23) "Undefined variable: buf" string(9) "/in/OtM0R" int(19) Fatal error: Wrong parameters for ErrorException([string $exception [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Exception $previous = NULL]]]]]]) in /in/OtM0R on line 6 string(17) "shutdown_function" array(4) { ["type"]=> int(1) ["message"]=> string(160) "Wrong parameters for ErrorException([string $exception [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Exception $previous = NULL]]]]]])" ["file"]=> string(9) "/in/OtM0R" ["line"]=> int(6) }
Process exited with code 255.

preferences:
162.57 ms | 402 KiB | 228 Q