note 88401 added to function.set-error-handler
| From: | Marcelius at osu1 dot php dot net | Date: | Thu, 22 Jan 2009 13:41:14 +0000 |
| Subject: | note 88401 added to function.set-error-handler | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-149652@lists.php.net to get a copy of this message | ||
Another way to catch PHP's fatal errors:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 0);
function shutdown(){
$isError = false;
if ($error = error_get_last()){
switch($error['type']){
case E_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
$isError = true;
break;
}
}
if ($isError){
echo "Script execution halted ({$error['message']})";
} else {
echo "Script completed";
}
}
register_shutdown_function('shutdown');
?>
Note that this will only catch runtime errors. So calling a method in a non existing class, or
declaring a function twice does not trigger the shutdown handler.
----
Server IP: 213.249.64.162
Probable Submitter: 80.126.216.238
----
Manual Page -- http://www.php.net/manual/en/function.set-error-handler.php
Edit -- https://master.php.net/note/edit/88401
Del: integrated -- https://master.php.net/note/delete/88401/integrated
Del: useless -- https://master.php.net/note/delete/88401/useless
Del: bad code -- https://master.php.net/note/delete/88401/bad+code
Del: spam -- https://master.php.net/note/delete/88401/spam
Del: non-english -- https://master.php.net/note/delete/88401/non-english
Del: in docs -- https://master.php.net/note/delete/88401/in+docs
Del: other reasons-- https://master.php.net/note/delete/88401
Reject -- https://master.php.net/note/reject/88401
Search -- https://master.php.net/manage/user-notes.php