Parenthesis determine the order in which comparisons are made. Your example is a pretty simple one that doesn't need parenthesis at all, but look at something like this
if ($a == 0 || $b == 0 && $c == 0 || $dd == 0)
This is actually equivalent to
if ($a == 0 || ($b == 0 && $c == 0) || $dd == 0)
because &&
is evaluated first in PHP as it has a higher precedence than the ||
IN most cases, when you have complex conditionals, you want to make sure to use parenthesis, if not to get the order of operations right, then at least to make it clear to the code reader what you are trying to do.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…