How to get relative error?

I created a custom error handler for php and set it to be my error handler but I still get fatal errors displayed, how do I stop it?

  • My php script still displays fatal error when I make a call to an unknown function, so as to test the error handler but I get fatal error still displayed. I have used the set_error_handler function to set my error handler function but still fatal errors are displayed.

  • Answer:

    There are several levels of errors that you must handle: common errors, fatal errors and uncaught exceptions. Combining these three functions you can set your own error handler for every on of them: set_error_handler(); set_exception_handler(); register_shutdown_function(); The trick to caught the fatal error is to register your own shutdown function and inside of it to check if the shutdown was triggered by an error. Here is an example how to do that: function handle_fatal_error() { $error = error_get_last(); if(isset($error['type']) && $error['type']!='') { // your own code...inside $error array you have all the details } }

Sven Al Hamad at Quora Visit the source

Was this solution helpful to you?

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.