note 94443 added to function.error-get-last
| From: | iant at clickwt dot com | Date: | Thu, 05 Nov 2009 17:13:10 +0000 |
| Subject: | note 94443 added to function.error-get-last | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-162419@lists.php.net to get a copy of this message | ||
Beware that registing a shutdown function to catch errors won't work if other shutdown
functions throw errors.
<?php
register_shutdown_function('cleanupObjects');
register_shutdown_function('handleFatalPhpError');
function cleanupObjects() {
trigger_error('An insignificant problem', E_USER_WARNING);
}
function handleFatalPhpError() {
$last_error = error_get_last();
if($last_error['type'] === E_ERROR || $last_error['type'] === E_USER_ERROR) {
echo "Can do custom output and/or logging for fatal error here...";
}
}
trigger_error('Something serious', E_USER_ERROR);
?>
In the above code, $last_error will contain the warning, becuase cleanupObjects() is called first.
----
Server IP: 92.48.74.199
Probable Submitter: 93.97.191.163
----
Manual Page -- http://www.php.net/manual/en/function.error-get-last.php
Edit -- https://master.php.net/note/edit/94443
Del: integrated -- https://master.php.net/note/delete/94443/integrated
Del: useless -- https://master.php.net/note/delete/94443/useless
Del: bad code -- https://master.php.net/note/delete/94443/bad+code
Del: spam -- https://master.php.net/note/delete/94443/spam
Del: non-english -- https://master.php.net/note/delete/94443/non-english
Del: in docs -- https://master.php.net/note/delete/94443/in+docs
Del: other reasons-- https://master.php.net/note/delete/94443
Reject -- https://master.php.net/note/reject/94443
Search -- https://master.php.net/manage/user-notes.php