note 91535 modified in function.set-error-handler by danbrown
| From: | danbrown@php.net | Date: | Tue, 16 Jun 2009 13:43:31 +0000 |
| Subject: | note 91535 modified in function.set-error-handler by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-156916@lists.php.net to get a copy of this message | ||
I have realized that a few people here mentioned that you cannot capture parse errors (type 4,
E_PARSE). This is not true. Here is how I do. I hope this helps someone.
1) Create a "auto_prepend.php" file in the web root and add this:
<?php
register_shutdown_function('error_alert');
function error_alert()
{
if(is_null($e = error_get_last()) === false)
{
mail('your.email@example.com', 'Error from auto_prepend',
print_r($e, true));
}
}
?>
2) Then add this "php_value auto_prepend_file /www/auto_prepend.php" to your .htaccess
file in the web root.
* make sure you change the email address and the path to the file.
--was--
I have realized that a few people here mentioned that you cannot capture parse errors (type 4,
E_PARSE). This is not true. Here is how I do. I hope this helps someone.
1) Create a "auto_prepend.php" file in the web root and add this:
register_shutdown_function('error_alert');
function error_alert()
{
if(is_null($e = error_get_last()) === false)
{
mail('user@site.com', 'Error from auto_prepend', print_r($e,
true));
}
}
2) Then add this "php_value auto_prepend_file /www/auto_prepend.php" to your .htaccess
file in the web root.
* make sure you change the email address and the path to the file.
http://php.net/manual/en/function.set-error-handler.php