I am in the middle of refining a rather large bit of code. Alot of it contains many general warnings and notices which do not affect the execution of the code (ie: undefined varilables, or array keys without qoutes).
I want to write a function which allows me to concentrate on the fatal errors first and then I will open it up to the less urgent warnings and notices. I found this code, but it emails every little warning notice and error.
http://net.tutsplus.com/tutorials/php/quick-tip-email-error-logs-to-yourself-with-php/
How can I modify this code so it only deals with things like:
- fatal syntax errors
- undefined functions
- failure to include files
set_error_handlerallows you to specify a user-defined error handling function for deciding what to do with certain (but only non-fatal) errors. You can then handle specific types of errors in any fashion you deem necessary, for example notifying a system administrator via email, or saving to a specific log file. See: PHP Doc for further details.With regards to your request you could the following approach:
As that error-handling does not work for Fatal Errors (Parse errors, undefined functions etc.), you need to tape this with
register_shutdown_functionas outlined in a related question: