Hey everyone,<br /><br />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.<br /><br />Thanks!<!--content-->
You can edit your PHP script and remove what ever is being echoed when an error occurs.<!--content-->
What about putting <b>error_reporting(0); </b> in your code, and then writing errors to a log?<!--content-->
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.<br /><br />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.<!--content-->
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?<!--content-->
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?<!--content-->
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.<!--content-->
I found a way to do exactly what I want. Check out the code snippet below...<br /><br /><div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-spacere;overflow:auto'><?php<br /><br /> ini_set('error_reporting', E_ALL | E_STRICT);<br /> ini_set('display_errors', 'Off');<br /> ini_set('log_errors', 'On');<br /> ini_set('error_log', '/path/to/errorlog');<br /><br />?></div><br /><br />That seems to do the trick!<!--content-->
Good find. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/thumbup1.gif" style="vertical-align:middle" emoid=":thumbup1:" border="0" alt="thumbup1.gif" /><br /><br />Glad you found a solution.<!--content-->
Great! Thanks for sharing your solution.<!--content-->
You can edit your PHP script and remove what ever is being echoed when an error occurs.<!--content-->
What about putting <b>error_reporting(0); </b> in your code, and then writing errors to a log?<!--content-->
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.<br /><br />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.<!--content-->
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?<!--content-->
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?<!--content-->
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.<!--content-->
I found a way to do exactly what I want. Check out the code snippet below...<br /><br /><div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-spacere;overflow:auto'><?php<br /><br /> ini_set('error_reporting', E_ALL | E_STRICT);<br /> ini_set('display_errors', 'Off');<br /> ini_set('log_errors', 'On');<br /> ini_set('error_log', '/path/to/errorlog');<br /><br />?></div><br /><br />That seems to do the trick!<!--content-->
Good find. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/thumbup1.gif" style="vertical-align:middle" emoid=":thumbup1:" border="0" alt="thumbup1.gif" /><br /><br />Glad you found a solution.<!--content-->
Great! Thanks for sharing your solution.<!--content-->