3v4l.org

run code in 300+ PHP versions simultaneously
<?php function myErrorHandler($errno, $errstr, $errfile, $errline) { if (!(error_reporting() & $errno)) { // This error code is not included in error_reporting return; } switch ($errno) { case E_USER_ERROR: echo "<b>My ERROR</b> [$errno] $errstr<br />\n"; echo " Fatal error on line $errline in file $errfile"; echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n"; echo "Aborting...<br />\n"; exit(1); break; case E_USER_WARNING: echo "<b>My WARNING</b> [$errno] $errstr<br />\n"; break; case E_USER_NOTICE: echo "<b>My NOTICE</b> [$errno] $errstr<br />\n"; break; case E_NOTICE: echo "Notice error type: [$errno] $errstr<br />\n"; break; default: echo "Unknown error type: [$errno] $errstr<br />\n"; break; } /* Don't execute PHP internal error handler */ return true; } function your_err_handler($errno, $errstr, $errfile, $errline, $errcontext) { $l = error_reporting(); if ( $l & $errno ) { $exit = false; switch ( $errno ) { case E_USER_ERROR: $type = 'Fatal Error'; $exit = true; break; case E_USER_WARNING: case E_WARNING: $type = 'Warning'; break; case E_USER_NOTICE: case E_NOTICE: case @E_STRICT: $type = 'Notice'; $exit = true; break; case @E_RECOVERABLE_ERROR: $type = 'Catchable'; break; default: $type = 'Unknown Error'; $exit = true; break; } $exception = new \ErrorException($type.': '.$errstr, 0, $errno, $errfile, $errline); if ( $exit ) { exc_handler($exception); exit(); } else throw $exception; } return false; } function exc_handler($exception) { $log = $exception->getMessage() . "\n" . $exception->getTraceAsString() . LINEBREAK; if ( ini_get('log_errors') ) error_log($log, 0); print("Unhandled Exception" . (DEBUG ? " - $log" : '')); } set_error_handler("your_err_handler"); $p = null; var_dump(isset($p)); var_dump(empty($p)); var_dump(is_null($p)); var_dump(isset($q)); var_dump(empty($q)); try{ var_dump(is_null($q)); } catch (Exception $e) { echo 'not set'; // throw new ErrorException($message, 0, $severity, $file, $line); } echo 'continuing';
Output for git.master, git.master_jit, rfc.property-hooks
bool(false) bool(true) bool(true) bool(false) bool(true) Fatal error: Uncaught ArgumentCountError: Too few arguments to function your_err_handler(), 4 passed in /in/FH46U on line 95 and exactly 5 expected in /in/FH46U:39 Stack trace: #0 /in/FH46U(95): your_err_handler(2, 'Undefined varia...', '/in/FH46U', 95) #1 {main} thrown in /in/FH46U on line 39
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
52.92 ms | 401 KiB | 8 Q