RE: [PHP] Simple error handling... but how? - Register your own error-handler with PHP
| From: | Neil Kimber | Date: | Tue, 09 Jan 2001 09:55:47 +0000 |
| Subject: | RE: [PHP] Simple error handling... but how? - Register your own error-handler with PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-33423@lists.php.net to get a copy of this message | ||
You can register your own error-handler using the function:
set_error_handler(<error_handler_function_name>);
Your customised error_handler will then get called whenever an error gets
called. Your function is passed the follwing parameters:
function error_handler_function_name($errno, $errstr, $errfile, $errline)
This is nice as it passes you the file and line number as well as the error
number and the error string. You can then use this for sending your own
informational debug messages to the error handler by using the
trigger_error() routine.
The handler that I use dumps everything to a debug file - using error_log().
This is great as I get all of my parsing errors and informational debug
messages sent to the same place. By sending them to a file (rather than the
screen) you stop headers being sent, which in turn could cause you problems.
I believe that this functionality only became available in 4.02.
You may also want to check out the assert() functions. These are similar and
are great for putting sanity checks into your code. I think that the assert
handler code was the inspiration for the error handling code.
Hope this helps,
Neil
-----Original Message-----
From: Diego Fulgueira [mailto:dful@metahogar.com]
Sent: 08 January 2001 22:00
To: Php-General
Subject: [PHP] Simple error handling... but how?
Ok. This might have been widely discussed already, but I haven't been able
to find useful information about it:
How can I present a customized error page whenever a PHP error or warning
ocurrs?
Thanks in advance.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net