< from cnmm22:http://blog.csdn.net/cnmm22/article/details/44810929>
$a = 0;
$b = 0;
If ($a =3| | $b =3) {
$a + +;
$b + +;
}
echo$a. ",". $b;
Write the result of the run.
The result is a.
The order of operations in the 1:if of knowledge points. In fact the order is, If ($a =3| | $b =3) {= If ($a = (3| | $b =3) {because | | The priority is greater than the assignment symbol.
Knowledge Point 2:| | Short circuit function, | | This is called short circuit or, (3| | $b =3) equals how much? equals 1, because (3| | $b =3) means 3 is it true? is True, | | The subsequent assignment operation $b=3 is no longer calculated, and finally, B is 0, because $b=3 is not executed at all, and (3| | $b =3) = True.
Knowledge point 3: In if ($a =3| | $b =3) {How much after a?} It says, (3| | $b =3) = True, that a is equal to true. In PHP, it's really equal to 1,a equals 1. Incidentally, in PHP is really 1, what is false? False is not 0, but empty, nothing.
So the result, a++ =1,b++=1.
That
$a = 0;
$b = 0;
If ($a =3| $b =3) {
$a + +;
$b + +;
}
echo$a. ",". $b;
What is the result of the operation?
The answer is 4, 4.
Here to pay attention to a knowledge point, or and a short circuit or. | Yes or, while | | Is the short circuit or, (3| $b =3) equal to how much? is equal to 3, because, first or will let the back $b =3 continue operation, so, B is equal to 3, in addition, or bit operation, so, (3| $b =3) = 3, so a=3.
A PHP face test