12

I'm checking the configuration of my PHP server and I need to set the following parameter as follows:

error_reporting set to E_ALL & ~E_NOTICE

However on my server a numeric value is set:

error_reporting 6135 6135

I was wondering what's the meaning of it, and if I really need to change it

thanks

abatishchev
  • 98,240
  • 88
  • 296
  • 433
aneuryzm
  • 63,052
  • 100
  • 273
  • 488
  • 1
    Either none of this makes any sense at all, or it's time for me to go to bed. – JAL Sep 21 '10 at 08:15

6 Answers6

17

Values used for error reporting

 E_RECOVERABLE_ERROR  4096 +
E_USER_NOTICE        1024 +
E_USER_WARNING        512 +
E_USER_ERROR          256 +
E_COMPILE_WARNING     128 +
E_COMPILE_ERROR        64 +
E_CORE_WARNING         32 +
E_CORE_ERROR           16 +
E_PARSE                 4 +
E_WARNING               2 +
E_ERROR                 1 +
                   = 6135
Mark Baker
  • 209,507
  • 32
  • 346
  • 385
12

From the page we have:

  • E_ALL has the value 30719 in PHP 5.3.x, 6143 in PHP 5.2.x, 2047 previously

  • E_NOTICE has the value 8

Looks like you are using PHP 5.2.x

Now If you do E_ALL & ~E_NOTICE Which is bitwise complement of E_NOTICE followed by bitwise anding with E_ALL we get

6143 & (~8) = 6135
codaddict
  • 445,704
  • 82
  • 492
  • 529
7

The error flags are power of 2 integers so you can combine them using bit operators. The result is an integer like the one you see so if you set it to E_ALL & ~E_NOTICE it will still end up as integer. What flags comprise the 6135 value depends on your php version. You can check if a flag is contained within it using the bitwise and operator, e.g.

if ((error_reporting() & E_NOTICE) == E_NOTICE) {
    echo "E_NOTICE is active";
}
Raoul Duke
  • 4,241
  • 2
  • 23
  • 18
  • `error_reporting() & E_NOTICE == 0` is wrong. First of all, `==` has a higher precedence than `&` so that `error_reporting() & E_NOTICE == 0` is equivalent to `error_reporting() & (E_NOTICE == 0)`. Furthermore, even if you would use `(error_reporting() & E_NOTICE) == 0`, it means that the expression is true if the return value of `error_reporting()` and the value of `E_NOTICE` have no bits in common. – Gumbo Sep 21 '10 at 08:35
  • ah yes. my bad. should be (error_reporting() & E_NOTICE) == E_NOTICE . thx and fixed – Raoul Duke Sep 21 '10 at 08:47
3
foreach(
    array('E_ALL', 'E_NOTICE', '~E_NOTICE', 'E_ALL&~E_NOTICE') 
    as $s) {
    eval("\$v=$s;");
    printf("%20s = dec %10u = bin %32b\n", $s, $v, $v);
}

result

           E_ALL = dec       6143 = bin                    1011111111111
        E_NOTICE = dec          8 = bin                             1000
       ~E_NOTICE = dec 4294967287 = bin 11111111111111111111111111110111
 E_ALL&~E_NOTICE = dec       6135 = bin                    1011111110111
user187291
  • 53,363
  • 19
  • 95
  • 127
1

Note, that error_reporting(-1); will report all and any PHP errors.

raveren
  • 17,799
  • 12
  • 70
  • 83
0

error_reporting 6135 will not log Runtime Notices, So better to use

error_reporting(E_ALL);

followed by

ini_set('display_errors', '0');

This will log all errors including Runtime notices, But pevent displaying in browser. This can be used in any PHP versions.

HYDER ALI
  • 86
  • 1
  • 1
  • 11