Bitwise operators allow you to turn specific bits within an integer on or off. If both the left- and right-hand parameters are strings, the bitwise operator will operate on the characters in this string.
echo 12 ^ 9; // Outputs '5'
echo "12" ^ "9"; // Outputs the Backspace character (ascii 8)
// ('1' (ascii 49)) ^ ('9' (ascii 57)) = #8
echo "hallo" ^ "hello"; // Outputs the ascii values #0 #4 #0 #0 #0
// 'a' ^ 'e' = #4
Table 11-3. Bitwise Operators
|$a & $b
||Bits that are set in both $a and $b are set.
|$a | $b
||Bits that are set in either $a or $b are set.
|$a ^ $b
Bits that are set in $a or $b but not both are set.
Bits that are set in $a are not set, and vice versa.
|$a << $b
Shift the bits of $a $b steps to the left (each step means "multiply by two")
|$a >> $b
Shift the bits of $a $b steps to the right (each step means "divide by two")