Reply to Re: Apache ErrorDocument / PHP header() interaction does not work as expected

Your name:

Reply:


Posted by gosha bine on 05/10/07 15:35

On 10.05.2007 11:19 liyanage@gmail.com wrote:

>
> I can actually have two separate status values, one that gets sent to
> the browser (Apache2::RequestRec::status()), and one that is returned
> to the Apache server (the handler() method's return value). Does
> something similar exist in PHP? Or do I really have to replicate the
> ErrorDocument functionality in my PHP code?

php module handler always returns OK (=200) to apache, no matter what
the script did. See for yourself:

http://lxr.php.net/source/php-src/sapi/apache2handler/sapi_apache2.c#487

I'm afraid, there's no way to change this behaviour in php code.

>
> 3.) While playing around with set_error_handler(), I also saw that
> syntax errors are not trappable with a custom error handler. I use an
> autoloader that loads classes on demand, and if one of the class files
> loaded at run-time has a syntax error, my error handler is bypassed.
> Combined with the inability to trigger ErrorDocuments described above,
> doesn't this mean that it is absolutely impossible to hide such errors
> from users by replacing them with a "friendly" error page when using
> PHP?

Cleanup callbacks (output buffering, destructors, shutdown functions)
are still executed in case of fatals, you can use them to produce nicer
post mortem error message, e.g.

function check_fatals($buf) {
if(strpos($buf, 'Fatal'))
return 'pardon!';
return $buf;
}

ob_start('check_fatals');
include 'whatever.php';


--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok

[Back to original 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

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