Bitwise Operations On String¶
The bit operators &, | and ^ work on integers, and use the numbers as a bitfield: each bit in the numbers are compared with the operator, and set accordingly in the result.
The same operators works on strings, where the string is treated as a binary data.
Since PHP 8.0, it is an error to have different types on both sides of the bit operators. Other types are also yielding an error, like with arrays, objects, etc.
When in doubt, consider using the logical operators.