The bitwise operators enable you to treat an integer as the series of bits used to represent it
PHP’s Bitwise Operators
Operator | Name | Use | Result |
---|---|---|---|
& | Bitwise AND | $a & $b | Bits set in $a and $b are set in the result |
| | Bitwise OR | $a | $b | Bits set in $a or $b are set in the result |
~ | Bitwise NOT | ~$a | Bits set in $a are not set in the result and vice versa. |
^ | Bitwise XOR | $a ^ $b | Bits set in $a or $b but not in both are set in the result. |
>> | Left shift | $a << $b | Shifts $a left $b bits |
<< | Left shift | $a << $b | Shifts $a left $b bits |