On Fri, April 28, 2006 11:55 am, IG wrote:
> 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.
Do they have .htaccess turned on?
Because you can set all this stuff in an .htaccess file...
> 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();
You do not need, nor even want probably, ob_start() just to be able to
use a custom error handler.
It doesn't HURT, mind you, but it's not needed at all.
> // custom error handler
> function e($type, $msg, $file, $line) {
> blah blah
> ob_end_clean();
>
> // display error page
> exit();
> }
>
> set_error_handler("e");
>
> But all I get is a blank page.
Well, unless your "blah blah" section outputs something, all you COULD
get is a blank page.
> Does having display_errors off mean
> that
> I can't use a custom error handler?
No, not at all.
> I have also tried adding
> *set_ini*('*display_errors*','1') but this keeps giving me a blank
> page.
What are all those * characters in there? Get rid of them.
> 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.
.htaccess, if it is on, will do this, and not require you to remember
to 'include' the error_handler on every script.
> I didn't really want to change display_errors to on as I was
> told this wasn't very secure-
That is correct.
It is too likely to expose too much information to Bad Guys.
> i don't want error messages on any of my
> pages, I just want a simple error 500 server error page.
Whoa.
Okay, now we are in a different kettle of fish...
I dunno that you CAN force a "500 server error" from within PHP...
I guess there ought to be a function for that somewhere, but I've
never noticed it...
It would probably be documented or linked from or discussed in the
User Contributed notes at http://php.net/header though, if it does
exist.
Would you settle for a nice HTML output like:
<p class="error">An error has occurred. Please try again later.</p>
Because that's pretty much a no-brainer with the error handler -- But
you have to actually output that.
I think your basic problem right now is the assumption that PHP exit()
with no content output would somehow constitute a 500 server error.
It doesn't.
[shrug]
There's nothing inherently "wrong" with the webserver returning a
totally blank document, really. Well, okay, by strict definitions of
HTML w3c standards, it's not valid HTML.
But it's also not a 500 error either.
As far as Apache is concerned, the document is "fine" and returns a
200. It just happens to be an empty/blank document is all.
--
Like Music?
http://l-i-e.com/artists.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php