Jump to content

Recommended Posts

Posted

Hey everyone,

 

Is there an easy way to disable PHP error text? I don't want to disable error reporting, just the error text. I'm afraid that it might expose script information that I don't want them to have.

 

Thanks!

Posted

TCH-Bruce: I'm not talking about script that echos an error, I'm talking about in case of a fatal php error or warning.

 

Yea I tried error_reporting(0) but that turns all error reporting off (obviously) so I'll never know that an error occurred. From the PHP manual it looks like there is a setting called "display_errors" which seems to be what I want. Anyone know how to get this turned off? It's simple on my own servers but for shared hosting I'm not sure how to do it.

Posted

Will this be a production site? The PHP documentation suggests that display_errors should not be used in production sites. Why not log all errors to a file? Won't that tell YOU about the errors that are occurring, without telling the user? And, if you did use error_reporting(0), isn't it still possible to log your errors in a file?

Posted

This will be a production site. How can you automatically log all php errors to a file? Setting error_reporting(0) won't report any errors ever, not even to a log file. Now I can write a script to catch php warnings but I can't catch and prevent fatal or complile errors without setting this value on the server instead of my files. Is there any way I can do this?

Posted

Wasn't sure if that would prevent logging of error messages. You can set your own error handling function. Go to php.net and look up the set_error_handler command. This lets you set the function that handles all errors.

Posted

I found a way to do exactly what I want. Check out the code snippet below...

 

><?php

   ini_set('error_reporting', E_ALL | E_STRICT);
   ini_set('display_errors', 'Off');
   ini_set('log_errors', 'On');
   ini_set('error_log', '/path/to/errorlog');

?>

 

That seems to do the trick!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...