Re: display_errors off and custom error pages
| From: | IG | Date: | Tue, 02 May 2006 07:07:02 +0000 |
| Subject: | Re: display_errors off and custom error pages | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-235234@lists.php.net to get a copy of this message | ||
Thanks, Jochem.
Jochem Maas wrote:
IG wrote:Good idea...I've spent the last couple of hours trying to work this out to no avail. I have recently moved over to a managed dedi server and no can ask my host to change my php.ini. I have found out that the 'display_errors' in the php.ini is set to off and error file logging is off. I would like to be able log to file which is easy to do from the ini file but also to show a custom error page if there is an error on one of the pages. I thought I would be able to use a custom error handler such as - ob_start(); // custom error handler function e($type, $msg, $file, $line) { blah blah ob_end_clean();while (@ob_end_clean()); // and header('Status: 500 Internal Server Error'); are things you should look at.
also the check the ini setting auto_prepend_file, which can be set in your apache config so that all vhosts share a common include file which defines and sets the errorhandler.Wow- didn't know about auto_prepend_file. That is a great setting- thanks for letting me know about it.
also apache has the ability to set a custom handler for 'real' 500 errors. the apache directive is something like: ErrorDocument 500 /path/to/my/500.php where the path is a url (or a local path - I think)// display error page exit(); } set_error_handler("e"); But all I get is a blank page. Does having display_errors off mean that I can't use a custom error handler? I have also tried adding *set_ini*('*display_errors*','1') but this keeps giving me a blank page. Can someone tell me the best (and most secure way) of having custom error pages in php. Ideally I would like it all set from a central place so that i only need to change one file for all the websites on our server. I didn't really want to change display_errors to on as I was told this wasn't very secure- i don't want error messages on any of my pages, I just want a simple error 500 server error page. Many thanks, Ian