Sunday 16 June 2019

php - What does this ~ operator mean here?



Example:




set_error_handler(array($this, 'handleError'), E_ALL & ~E_STRICT & ~E_WARNING & ~E_NOTICE);


what does that suppose to mean?


Answer



It is the bitwise not operator (also called "complement"). That is the bits set in ~ $a are those that are not set in $a.



So then



E_ALL & ~E_STRICT & ~E_WARNING & ~E_NOTICE



is the bits set in E_ALL and those not set in E_STRICT, E_WARNING and E_NOTICE. This basically says all errors except strict, warning and notice errors.


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...