By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,934 Members | 1,677 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,934 IT Pros & Developers. It's quick & easy.

provide pretty page for fatal errors?

P: n/a
Hi,

Is it possible in PHP to provide a nice pretty page when a fatal error
occurs? (Or any of the errors listed here
http://uk.php.net/manual/en/function...or-handler.php 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.

Si

Oct 27 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Simon Kittle schreef:
Is it possible in PHP to provide a nice pretty page when a fatal error
occurs? (Or any of the errors listed here
http://uk.php.net/manual/en/function...or-handler.php 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.
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:

<?php

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

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.

HTH;
JW
Oct 27 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.