Why if ($ a100 & amp; $ b200) {var_dump ($ a, $ B) ;}output bool (true) int (200) {code ...}
Why?if ($a = 100 && $b = 200) {var_dump($a, $b);}Output bool (true) int (200)
Reply content:
Why?if ($a = 100 && $b = 200) {var_dump($a, $b);}Output bool (true) int (200)
&&Priority ratio=High, so will$a = (100 && $b = 200)In http://php.net/manual/en/language.operators.precedence.php
Although = has a lower precedence than most other operators, PHP will still allow expressions similar to the following: if (!$a = foo()), in which case the return value of foo() is put into $a., Although&&Priority higher=,200Will be assigned$b, Because100 && $b = 200Returns truetrue, So$a=true
The actual priority is as follows:
Therefore, $ a is true.
Assignment is not a comparison. you may have read it wrong.
I have been talking about it all the time.
Actually, this is how it runs.
php
if($a = (100 && $b = 200)){ var_dump($a, $b);}