provide pretty page for fatal errors?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Is it possible in PHP to provide a nice pretty page when a fatal error
occurs?  (Or any of the errors listed here which you
cannot catch).

I have error_reporting turned off as I have a production server - but
that just gives a blank page which is less than good.


Re: provide pretty page for fatal errors?

Simon Kittle schreef:
Quoted text here. Click to load it

With these kind of errors, the parsing comes to a dead stop, hence why  
you cannot apply user-defined functions to handle them.

This implies that you cannot do anything on the server level to handle  
these errors.

Client-side, however, you could use javascript to forward to a new page  
or print a message. Example:


print <<<EOS
    window.onload = function () {
        if (!window.ok) {
            document.location = 'error.html';


print '<script>var ok = 1</script>';


In this case, the call to the undefined foo() function causes a fatal  
error, so var ok gets never set and the onload action redirects the user  
to error.html

When foo() is defined, var ok will be printed and the onload function  
will do nothing.


Site Timeline