Bitwise Operators in php

The bitwise operators enable you to treat an integer as the series of bits used to represent it

PHP’s Bitwise Operators

OperatorNameUseResult
&Bitwise AND$a & $bBits set in $a and $b are set in the result
|Bitwise OR$a | $bBits set in $a or $b are set in the result
~Bitwise NOT~$aBits set in $a are not set in the result and
vice versa.
^Bitwise XOR$a ^ $bBits set in $a or $b but not in both are set in
the result.
>>Left shift$a << $bShifts $a left $b bits
<<Left shift$a << $bShifts $a left $b bits
PHP’s Bitwise Operators

Leave a Comment