5

I need PHP errors not to be displayed but logged. I am using PHP 5.4 My current code to log errors in my php.ini is:

log_errors = 1
error_log = "/path-to-file/error_log.txt"

Which works however I am getting a 500 internal server error trying to turn error displaying off using display_errors. I have tried using the following, all returning 500 errors.

display_errors = 0
display_errors = "0"
display_errors = false
display_errors = "false"
display_errors = Off
display_errors = "Off"

According to the PHP documentation, as of PHP 5.4, it is a string. What am I suppose to set display_errors to to turn error displaying off?

10
  • What server? What method of executing PHP? FastCGI? Commented Sep 9, 2012 at 3:36
  • I am using Apache on Linux with 1&1 hosting. I'm not sure what you mean by "What method of executing PHP?" @Brad Commented Sep 9, 2012 at 3:37
  • So on your production code it's possible to get fatal error? How's that possible? Commented Sep 9, 2012 at 3:38
  • 1
    If I remember correctly, this is a server configuration thing, and not a PHP configuration problem. Your errors are not being displayed... that part is working fine. You just need to get your web server to not return the 500 status code and page when an error occurs. Commented Sep 9, 2012 at 3:39
  • @zerkms No it is not possible to get a fatal error, however I want to turn off displaying errors just in case I do get an error. Commented Sep 9, 2012 at 3:40

1 Answer 1

4

a 500 error code means there is an invalid server configuration. This is most likely coming from Apache and not from php.

To get a clear understanding on what is giving you the error, look at your apache logs.

If you wish to also hide the 500 error, you could open your httpd.conf file and add

ErrorDocument 500 " "

Then make sure to restart apache. Any time you make a config change to php.ini or httpd.conf you will need to restart apache for it to take into effect.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.