Using ~ before E_NOTICE

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mikebr
Forum Contributor
Posts: 243
Joined: Sat Sep 28, 2002 7:05 am

Using ~ before E_NOTICE

Post by mikebr »

Been trying to find out why one might use a tilde '~' before E_NOTICE such as:

Code: Select all

error_reporting(E_ALL & ~E_NOTICE);
@ini_set('display_errors', 1);
Searched around the web and in the manual without any joy, If someone could explain the difference of using a ~ or not please?

Thanks in advance
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Using ~ before E_NOTICE

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
semlar
Forum Commoner
Posts: 61
Joined: Fri Feb 20, 2009 10:45 pm

Re: Using ~ before E_NOTICE

Post by semlar »

It's a bitwise operator.. means negation. The ampersand is bitwise AND.

Error reporting is measured in bit values, and negating one basically tells it not to report that type of error.

Ah, you beat me to it, I'll leave this here anyway.
mikebr
Forum Contributor
Posts: 243
Joined: Sat Sep 28, 2002 7:05 am

Re: Using ~ before E_NOTICE

Post by mikebr »

Great thanks
Post Reply