views:

625

answers:

2

I am using PHP.

Could anyone explain differences between error_reporting(E_ALL) and error_reporting(E_ALL & ~E_NOTICE)?

I noticed that when I change from E_ALL to E_ALL & ~E_NOTICE, an error which I was hacking, disappears.

Regards.

+1  A: 

E_ALL would should all the error and warning and notice - everything

E_NOTICE is a special error level, showing things that won't produce error but are not good or gonna be obsolete in future release of PHP. The notice error level is meant to encourage best practices.

Also it should be error_reporting(E_ALL ^ E_NOTICE); to report everything except notice.

You are advice during development to set the error reporting to E_ALL and fix all the notice errors.

a look in the manual would give much more details.

RageZ
+2  A: 

E_ALL is "everything"

E_ALL & ~E_NOTICE is "everything except notices"

Notices are the least-urgent kinds of messages. But they can be very useful for catching stupid programmer mistakes, like trying to read from a hash with a non-existent key, etc.

(To understand the syntax, read up on bitwise operators)

timdev