Richard Lynch wrote:
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?
I've checked and it isn't I have asked my host to do this now. However
I'd ideally like everything sorted from the Apache config file.
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.
I thought I needed ob_start(), why don't I? If part of a page is
outputted then it would be impossible to output an error page as html
has already been sent out.
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.
Yes- blah, blah was just a nicely formatted and helpful error page that
won't scare off customers.
Does having display_errors off mean
that
I can't use a custom error handler?
No, not at all.
At the moment I have display_errors off and the above script does not
work for some reason. I have tried to put errors into scripts but all I
get is a blank page. The other question is do custom error handlers work
for parse errors? Again I would ideally like a custom error page to be
displayed for all errors including parse errors just in case I make a
mistake- I'm always forgetting those ';'s!
I have also tried adding
*set_ini*('*display_errors*','1') but this keeps giving me a blank
page.
I don't know where the *s got in in this email- I didn't type them!
Anyway it is still 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.
I thought I might be able to do this by setting an error 500 header with
php using the header() command.
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.
Good point- web standards are the way forward!
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.
Blank pages aren't that helpful to a user though.
Many thanks for your help.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php