3v4l.org

run code in 300+ PHP versions simultaneously
<?php $old_error = error_reporting(); $new_old_error = null; $bool = false; $string = ''; $get_last = array(); // error handler function function myErrorHandler($errno, $errstr, $errfile, $errline) { global $new_old_error, $bool, $string, $get_last; $new_old_error = error_reporting(); if (!($new_old_error & $errno)) { // This error code is not included in error_reporting, so let it fall // through to the standard PHP error handler $get_last[] = error_get_last(); //error_clear_last(); } else { // $errstr may need to be escaped: $errstr = htmlspecialchars($errstr); switch ($errno) { case E_USER_ERROR: $string = $string . "<b>My ERROR</b> [$errno] $errstr<br />\n"; $string = $string . " Fatal error on line $errline in file $errfile"; $string = $string . ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n"; $string = $string . "Aborting...<br />\n"; exit(1); case E_USER_WARNING: $string = $string . "<b>My WARNING</b> [$errno] $errstr<br />\n"; break; case E_USER_NOTICE: $string = $string . "<b>My NOTICE</b> [$errno] $errstr<br />\n"; break; default: $string = $string . "Unknown error type: [$errno] $errstr<br />\n"; break; } /* Don't execute PHP internal error handler */ $bool = true; } return $bool; } $old_error_handler = set_error_handler("myErrorHandler"); @$arr['is']; var_dump($string, $get_last);
Output for 8.1.0 - 8.1.29, 8.2.0 - 8.2.21, 8.3.0 - 8.3.9
string(0) "" array(2) { [0]=> NULL [1]=> array(4) { ["type"]=> int(2) ["message"]=> string(23) "Undefined variable $arr" ["file"]=> string(9) "/in/6DbhM" ["line"]=> int(51) } }

preferences:
85.37 ms | 404 KiB | 67 Q