|
Post by thundergod2k2 on Apr 21, 2007 21:22:33 GMT
I've never used any form of my own error handling, but as I've come across scripts for resource, I always see variables like $errno, $errstr, etc. without them actually being declared initially. Are they predefined to hold the error number and string when an error occurs?
|
|
|
Post by Graeme on Apr 22, 2007 18:22:00 GMT
uk.php.net/set-error-handlerYou must set your own error handling function through: set_error_handler('FUNCTION_NAME');The error details are passed as parameters to that function; in this order: - errno
- errstr
- errfile
- errline
- errcontext
Only errno and errstr are required; the rest are optional. The parameters you enter when constructing your function are the ones used to refer to the error. For instance: <?php
function myErr($error_number, $error_string){ echo 'ERROR['.$error_number.'] - '.$error_string; }
set_error_handler('myErr');
?> Notice the use of the variables $error_number and $error_string. Hope that clears things up *Just a little note. "The following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT raised in the file where set_error_handler() is called."
|
|
|
Post by thundergod2k2 on Apr 29, 2007 9:06:58 GMT
I didn't really need help with creating my own error handler, I just wanted to know if the variables $errno and $errstr are given values by PHP, since in the scripts I've seen that use them I've never seen it ever manually put any values into them.
|
|
|
Post by Graeme on Apr 30, 2007 16:09:34 GMT
Yes, and i showed how those variables are given.
I thought that would have been more helpful...
|
|