When programming in C, I often get the advice to turn on many or all warnings and not ignore warnings.

Does the same hold in PHP, should I enable all warnings in the PHP log?

4 Answers 4


Default log level for PHP excludes notices, ie. it's E_ALL & ~E_NOTICE for PHP 5.2, E_ALL & ~E_NOTICE & ~E_STRICT for 5.3 and E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED for 5.4.

If you're working only with your code, then you're much better off setting it to E_ALL. Seeing notices will save you lot of debugging time, seeing deprecation and compatibility notices, will save you a lot of pain upgrading to newer PHP.

However, if you're working with third party code, turning on all notices (E_NOTICE, E_STRICT and E_DEPRECATED) can lead to spamming of your log, as a lot of older code will generate a notice every few lines of code.

  • Slight clarification although I agree with everything you've said...the most current php.ini defaults are: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED; Development Value: E_ALL; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT.
    – jcmeloni
    Mar 15, 2012 at 12:16
  • E_STRICT is not included in E_ALL (unless you're already using 5.4)
    – vartec
    Mar 15, 2012 at 12:27
  • Right, "current" meaning 5.4.x -- I just had the ini files open at the same time I was reading your answer and yanked the text right from it.
    – jcmeloni
    Mar 15, 2012 at 12:29
  • ok, edited.. hope it's less ambiguous now
    – vartec
    Mar 15, 2012 at 12:49
  • That's excellent!
    – jcmeloni
    Mar 15, 2012 at 12:58

Yes, of course. Why on Earth would you not want to automatically catch as many problems and potential issues as you can, especially when starting from scratch?

  • I was told by a colleague that "it's not realistic" to run with all warnings on. Mar 15, 2012 at 11:05
  • 1
    In production it's not something looked well upon to display error messages. Since it'll log to file anyways it shouldn't matter. In development, always work with error codes being displayed (or otherwise work with a running tail on the apache error_log file, whichever works for you.)
    – Mike S
    Mar 15, 2012 at 11:17
  • 1
    "Not realistic" is not a realistic reason. What are the actual problems one encounters when all warnings are enabled? Mar 15, 2012 at 14:17

Enabling warnings in PHP gives an extra edge for a programer to know where his coding is going wrong on which page , line etc... imagine manually checking 1000's of line to catch an error, if you have included multiple files, then you need to check as many as you have got. Therefore, it is better practise to enable it for a programer point of view!.


In development phase of project I prefer to have: "E_ALL | E_STRICT" with display_errors turned on too so I can get all possible warning/erors/notices and so on. Just a simple lapsus in $user vs $usr can create a whole bunch of problems later and PHP without this setting will not create build problems but will generate broken bussiness logic.

In production mode it is best to have them turned on too but disabled display_errors flag. You can create your own custom error handler so logs can be written there or use for instance Apaches error log to find them (custom ones are better since you can write down more context that you need)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.