For
$a < $b || $c == $d && $e < $f
Can it be understood like this:
$a < $b || $c == $d;
At the same time
$c == $d && $e < $f;
And
$a < $b has no logical relationship with $e < $f?
Are the priorities in other languages also used this way?
For
$a < $b || $c == $d && $e < $f
Can it be understood like this:
$a < $b || $c == $d;
At the same time
$c == $d && $e < $f;
And
$a < $b has no logical relationship with $e < $f?
Are the priorities in other languages also used this way?
$a < $b || ($c == $d && $e < $f)
&& has higher priority than || .
Owner, please don’t take advantage of this. Writing like this is not allowed in team development.
Three logical operators from high to low: not and or
First of all, this way of writing is not recommended during development and will generally be killed.
1. This expression has comparison operators and logical operators, including logical operator && and logical operator ||.
For PHP, the comparison operator has a higher priority than the logical operators && and ||, but the logical operator && has a higher priority than the logical operator ||
$a < $b || $c == $d && $e < $f
So the result is like this: The first step is operator comparison: ($a<$b)| |($c==$d)&&($e<$f)
Compare || or &&
If ($a<$b) is true, then the expression result is Is true
If: ($a<$b) is fasle, and one of ($c==$d) and ($e<$f) is fasle, the result is false.
These are all experts...I never study this kind of problem, it’s very troublesome
<code>(($a < $b) || ($c == $d)) && ($e < $f)</code>
Isn’t this bad?
Do you promise not to look at this code again? Don’t you need to think when you watch it? So why bother yourself?