How can I catch ALL errors in PHP? -


i've found lot of attempts @ all-inclusive error handling implementations, , figured might write wiki-style provide complete solution came with.

the question is:

"how might 1 catch, handle, or intercept error types in php?"

now - might deemed 'rewrite' - don't know there's been comprehensive solution proposed.

there 3 kinds of error handlers need:

  • set_exception_handler, catch otherwise uncaught exceptions.

  • set_error_handler catch "standard" php errors. first check against error_reporting see if it's error should handled or ignored (i ignore notices - bad that's choice), , throw errorexception, letting exception handler catch outputting.

  • register_shutdown_function combined error_get_last. check value of ['type'] see if e_error, e_parse or fatal error types want catch. these bypass set_error_handler, catching them here lets grab them. again, tend throw errorexception, errors end being handled same exception handler.

as how implement these, depends entirely on how code set up. ob_end_clean() purge output, , present nice error page telling them error has been reported.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -