You are here: Re: provide pretty page for fatal errors? « PHP Programming Language « IT news, forums, messages
Re: provide pretty page for fatal errors?

Posted by Janwillem Borleffs on 10/27/06 15:06

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.set-error-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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация