When comparing the result of a bit operation, we suggest to add explicit
parenthesis and not to rely on PHP’s built-in operator precedence to ensure
the code behaves as intended and to make it more readable.
Let’s take a look at these examples:
// Returns always int(0).return0===$foo&4;return(0===$foo)&4;// More likely intended return: true/falsereturn0===($foo&4);
When comparing the result of a bit operation, we suggest to add explicit parenthesis and not to rely on PHP’s built-in operator precedence to ensure the code behaves as intended and to make it more readable.
Let’s take a look at these examples: