0

How do I set PHP to display warnings and errors and not to show notices?

4
  • 5
    But you should also take care of the notices. They are there for a reason. Just disable them does not make the potential problem go away. Commented Dec 19, 2010 at 1:37
  • @FelixKling: It sufficies to be notified once, since the issues are normally speculative. There is a difference between ignoring them and just disabling their display. (Btw, custom error handlers [logs] still can see them, whereas syntactic isset salt will forfeit them completely.) Commented Dec 19, 2010 at 2:36
  • 1
    @mario: Disabling error_reporting E_NOTICE level not only disables their display, but the logging as well. You can enable the PHP ignore_repeated_errors INI directive to be notified only once if you want to. No need to completely disable E_NOTICE. Commented Dec 19, 2010 at 4:40
  • @netcoder: Depends. Using a set_error_handler will get you all notices even for error_reporting(0), which I use for logging to unclog the httpd.log. Nice tip on the ignore_repeated_errors, seems rather useful for development stage. Commented Dec 19, 2010 at 4:44

1 Answer 1

4

Put this into your php.ini file:

error_reporting = E_ERROR | E_WARNING
display_errors  = 1

EDIT: As @Felix said, you should probably have those notices show as well. They are there for a reason.

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

3 Comments

do you know how to set this from php.ini file?
@Adamski Find display_errors and set it to 1. error_reporting() is a runtime setting I'm pretty sure.
How do you set this in /etc/apache2/sites-available using php_value?

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.