PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hello,
I'm writing my own error logging handler function that writes php errors to disk. I cannot figure out how to capture errors that come from calling an undefined function or malformed php statements. If I set php to display all errors, I can see these errors displayed on my browser, however these errors don't appear to invoke my error handler function.
Here are the php calls I'm making to setup my error logger:
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.
I have to ask why you would want to log that kind of error...compile time errors are really only of interest once and should be fixed ASAP and forgotten.
Missing functions are possibly somethign worth logging, in the case where you have dynamically loaded modules, etc...
In this case, I wouldn't rely on error logging but rather a conditional check to see if the function/method/class exists and if not, log the error and throw an exception...
Yeah, normally I wouldn't care to log such errors. However, recently I had to spend a whole day tracking a bug due to a missing function. The problem was really due to the fact that my development environment was running a later version of php than my production environment. A rookie mistake, but having php log an error to disk for an unrecognized function would have been nice.