This article has moved.
Catching PHP Errors
2 Comments to “Catching PHP Errors”
-
hi,
a small notice on “Type 3. Fatal Errors” and “error_get_last()”:
PHP-internal-Exceptions are hybrid (Exceptions and Errors)!1. if you throw own exceptions “error_get_last()” returns NULL
2. if PHP throws (internal!) exceptions “error_get_last()” returns exception-data!so you end up logging catched exceptions/errors.
Code:
ini_set('display_errors', true);
date_default_timezone_set('UTC');try {
throw new \Exception('crypto');
} catch (\Exception $e) {
echo 'Exception: ' . var_export($e, true) . '';
}echo 'error_get_last: ' . var_export(error_get_last(), true) . '';
try {
new DateTime('compress');
} catch (\Exception $e) {
echo 'Exception: ' . var_export($e, true) . '';
}echo 'error_get_last: ' . var_export(error_get_last(), true) . '';
more info:
http://de2.php.net/manual/en/errorfunc.configuration.php#ini.track-errors
http://bugs.php.net/bug.php?id=54043