note 32316 modified in function.trigger-error by danbrown
| From: | danbrown@php.net | Date: | Fri, 06 Feb 2015 15:33:28 +0000 |
| Subject: | note 32316 modified in function.trigger-error by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-201653@lists.php.net to get a copy of this message | ||
the idea is never to give out file names, line numbers, and cryptic codes to the user. Use
trigger_error() after you used set_error_handler() to register your own callback function which
either logs or emails the error codes to you, and echo a simple friendly message to the user.
And turn on a more verbose error handler function when you need to debug your scripts. In my
init.php scripts I always have:
if (_DEBUG_) {
set_error_handler ('debug_error_handler');
}
else {
set_error_handler ('nice_error_handler');
}
--was--
sl0th, the idea is never to give out file names, line numbers, and cryptic codes to the user. Use
trigger_error() after you used set_error_handler() to register your own callback function which
either logs or emails the error codes to you, and echo a simple friendly message to the user.
And turn on a more verbose error handler function when you need to debug your scripts. In my
init.php scripts I always have:
if (_DEBUG_) {
set_error_handler ('debug_error_handler');
}
else {
set_error_handler ('nice_error_handler');
}
http://php.net/manual/en/function.trigger-error.php