Copy codeThe Code is as follows: <? Php
$ A = 3;
$ B = 6;
If ($ a = 5 | $ B = 7 ){
$ A ++;
$ B ++;
}
Var_dump ($ a, $ B );
Trap 1
Consider $ a = 5 and $ B = 7 as $ a = 5 and $ B = 7.
Error result: 3, 6
Trap 2
Operator priority. $ a = 5 is assigned successfully. $ B = 7 is not executed.
Error result: 6, 7
Correct understanding
The trap is the priority of the operator, and the priority of the value assignment operator (=) is the lowest, so the correct understanding should be
$ A = (5 | $ B = 7)
Correct results: true, 7
Upgrade
Deformation 1 Copy codeThe Code is as follows: $ a = 3;
$ B = 6;
$ C = 1;
If ($ a = 5 | $ B = 7 & $ c = 10 ){
$ A ++;
$ B ++;
}
Var_dump ($ a, $ B, $ c );
Deformation 2 Copy codeThe Code is as follows: $ a = 3;
$ B = 6;
$ C = 1;
If ($ a = 0 | $ B = 7 & $ c = 10 ){
$ A ++;
$ B ++;
}
Var_dump ($ a, $ B, $ c );
If you are interested, you can think about it :)