The content shared with you in this article is about bit operations in PHP, which has certain reference value. Friends in need can refer to it
$a & $b |
And (bitwise AND) | will set the bits in and that are both 1 to 1. |
$a | $b |
Or (bitwise OR) | will combine and Any bit that is 1 is set to 1. |
$a ^ $b |
Xor (bitwise XOR) | will combine The bit where one is 1 and the other is 0 is set to 1. |
~ $a |
Not (bitwise negation) | will be 0 in Bit is set to 1 and vice versa. |
$a << $b | Shift left | The bits in are shifted to the left times (each shift means "multiply by 2"). |
$a >> $b |
Shift right | The bits in are shifted to the right times (each shift means "divide by 2"). |
The above is the detailed content of Bit operations in php. For more information, please follow other related articles on the PHP Chinese website!