Copy CodeThe code is as follows:
$a = 3;
$b = 6;
if ($a =5| | $b =7) {
$a + +;
$b + +;
}
Var_dump ($a, $b);
Trap One
Take $a=5, $b = 7 as $a==5, $b ==7
Error Result: 3,6
Trap Two
Operator precedence, $a=5 assignment is considered successful $b=7 not executed
Error Result: 6,7
Correct understanding
The trap is the precedence of the operator, and the assignment operator (=) has the lowest precedence, so the correct understanding should be
$a = (5| | $b =7)
Correct result: true,7
Upgrade
Deformation one
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 two
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);
Interested students can think about:)
http://www.bkjia.com/PHPjc/326013.html www.bkjia.com true http://www.bkjia.com/PHPjc/326013.html techarticle Copy the code as follows: PHP $a =3; $b =6; if ($a =5| | $b =7) {$a + +; $b + +;} var_dump ($a, $b); Trap a $a=5, $b = 7 as the $a==5, $b ==7 error results: 3,6 trap Two operators of the excellent ...