note 125103 deleted from function.register-shutdown-function by crell

From: Date: Thu, 31 Mar 2022 17:08:06 +0000
Subject: note 125103 deleted from function.register-shutdown-function by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-217862@lists.php.net to get a copy of this message
Note Submitter: ohcc at 163 dot com ---- As of PHP 7.4, an exception thrown within the user-defined shutdown function can be caught by the user-defined exception handler. <?php set_error_handler( function($level, $error, $file, $line){ if(0 === error_reporting()){ return false; } throw new ErrorException($error, -1, $level, $file, $line); }, E_ALL ); register_shutdown_function(function(){ $error = error_get_last(); if($error){ throw new ErrorException($error['message'], -1, $error['type'], $error['file'], $error['line']); } }); set_exception_handler(function($exception){ // ... more code ... }); require 'NotExists.php';

« previous php.notes (#217862) next »