note 64060 added to function.error-reporting
| From: | dave at davidhbrown dot us | Date: | Thu, 06 Apr 2006 15:51:38 +0000 |
| Subject: | note 64060 added to function.error-reporting | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107446@lists.php.net to get a copy of this message | ||
The example of E_ALL ^ E_NOTICE is a 'bit' confusing for those of us not wholly conversant
with bitwise operators.
If you wish to remove notices from the current level, whatever that unknown level might be, use
& ~ instead:
<?php
//....
$errorlevel=error_reporting();
error_reporting($errorlevel & ~E_NOTICE);
//...code that generates notices
error_reporting($errorlevel);
//...
?>
^ is the xor (bit flipping) operator and would actually turn notices *on* if they were previously
off (in the error level on its left). It works in the example because E_ALL is guaranteed to have
the bit for E_NOTICE set, so when ^ flips that bit, it is in fact turned off. & ~ (and not) will
always turn off the bits specified by the right-hand parameter, whether or not they were on or off.
----
Server IP: 66.163.161.117
Probable Submitter: 68.9.252.218
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.error-reporting.php
Edit -- http://master.php.net/note/edit/64060
Del: integrated -- http://master.php.net/note/delete/64060/integrated
Del: useless -- http://master.php.net/note/delete/64060/useless
Del: bad code -- http://master.php.net/note/delete/64060/bad+code
Del: spam -- http://master.php.net/note/delete/64060/spam
Del: non-english -- http://master.php.net/note/delete/64060/non-english
Del: in docs -- http://master.php.net/note/delete/64060/in+docs
Del: other reasons-- http://master.php.net/note/delete/64060
Reject -- http://master.php.net/note/reject/64060
Search -- http://master.php.net/manage/user-notes.php