3v4l.org

run code in 300+ PHP versions simultaneously
<?php $old_error = error_reporting(); $new_old_error = null; $bool = false; $string = ''; $get_last[0] = 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']; @$as['55']; var_dump($string, $get_last, error_get_last());
Output for 8.3.0 - 8.3.3
string(0) "" array(5) { [0]=> array(0) { } [1]=> NULL [2]=> array(4) { ["type"]=> int(2) ["message"]=> string(23) "Undefined variable $arr" ["file"]=> string(9) "/in/WaODB" ["line"]=> int(51) } [3]=> array(4) { ["type"]=> int(2) ["message"]=> string(37) "Trying to access array offset on null" ["file"]=> string(9) "/in/WaODB" ["line"]=> int(51) } [4]=> array(4) { ["type"]=> int(2) ["message"]=> string(22) "Undefined variable $as" ["file"]=> string(9) "/in/WaODB" ["line"]=> int(52) } } array(4) { ["type"]=> int(2) ["message"]=> string(37) "Trying to access array offset on null" ["file"]=> string(9) "/in/WaODB" ["line"]=> int(52) }
Output for 8.1.0 - 8.1.27, 8.2.0 - 8.2.16
string(0) "" array(5) { [0]=> array(0) { } [1]=> NULL [2]=> array(4) { ["type"]=> int(2) ["message"]=> string(23) "Undefined variable $arr" ["file"]=> string(9) "/in/WaODB" ["line"]=> int(51) } [3]=> array(4) { ["type"]=> int(2) ["message"]=> string(51) "Trying to access array offset on value of type null" ["file"]=> string(9) "/in/WaODB" ["line"]=> int(51) } [4]=> array(4) { ["type"]=> int(2) ["message"]=> string(22) "Undefined variable $as" ["file"]=> string(9) "/in/WaODB" ["line"]=> int(52) } } array(4) { ["type"]=> int(2) ["message"]=> string(51) "Trying to access array offset on value of type null" ["file"]=> string(9) "/in/WaODB" ["line"]=> int(52) }

preferences:
60.21 ms | 404 KiB | 54 Q