note 98606 added to function.error-get-last
| From: | scott at eyefruit dot com | Date: | Fri, 25 Jun 2010 20:47:48 +0000 |
| Subject: | note 98606 added to function.error-get-last | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-170474@lists.php.net to get a copy of this message | ||
If you have the need to check whether an error was a fatal error before PHP 5.2 (in my case, within
an output buffer handler), you can use the following hack:
<?php
# Check if there was a PHP fatal error.
# Using error_get_last is the "right" way, but it requires PHP 5.2+. The back-up is a
hack.
if (function_exists('error_get_last')) {
$lastPHPError = error_get_last();
$phpFatalError = isset($lastPHPError) && $lastPHPError['type'] === E_ERROR;
} else {
$phpFatalError = strstr($output, '<b>Fatal error</b>:') && !
strstr($output, '</html>');
}
?>
This is, of course, language-dependent, so it wouldn't be good in widely-distributed code, but
it may help in certain cases (or at least be the base of something that would work).
----
Server IP: 208.69.120.55
Probable Submitter: 158.158.240.231
----
Manual Page -- http://www.php.net/manual/en/function.error-get-last.php
Edit -- https://master.php.net/note/edit/98606
Del: integrated -- https://master.php.net/note/delete/98606/integrated
Del: useless -- https://master.php.net/note/delete/98606/useless
Del: bad code -- https://master.php.net/note/delete/98606/bad+code
Del: spam -- https://master.php.net/note/delete/98606/spam
Del: non-english -- https://master.php.net/note/delete/98606/non-english
Del: in docs -- https://master.php.net/note/delete/98606/in+docs
Del: other reasons-- https://master.php.net/note/delete/98606
Reject -- https://master.php.net/note/reject/98606
Search -- https://master.php.net/manage/user-notes.php