I think I might have found something at last:
Travis Raybold wrote:
the way i can handle fatal errors is to first thing on every page send a
Location header that redirects to the error page, and if i get a fatal
error it goes to the error page. if i finish the page normally, the last
bit of code i have resets the Location header. this necessitates turning
off buffering, obviously.
I think he means turning buffering on. Second thing - header calls aren't buffered, but maybe a meta refresh. Proof of concept:
<?php
ob_start();
echo "<meta http-equiv=\"refresh\" content=\"0;url=http://wikipedia.org\" />";
echo "Page content";
//undefinedFunction(); //fatal error - works
//require('foobar.php'); //fatal error - works
//trying to timeout
while (true)
{
$i = 1;
}//works as well
//if everything is allright
$page = str_replace("<meta http-equiv=\"refresh\" content=\"0;url=http://wikipedia.org\" />","",ob_get_contents());
ob_end_clean();
echo $page;
?>
What do you think about this? Would output buffering make user wait considerably longer for the page to load? I have a template system anyway (Smarty), so the application does everything before displaying anything.