Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are differences between error_reporting(E_ALL) and error_reporting(E_ALL & ~E_NOTICE)

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.

like image 962
shin Avatar asked Nov 05 '09 07:11

shin


2 Answers

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)

like image 169
timdev Avatar answered Oct 24 '22 02:10

timdev


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.

like image 35
RageZ Avatar answered Oct 24 '22 03:10

RageZ