This condition 1 and (0 OR condition 2) How logical operations are understood

Source: Internet
Author: User
This condition 1 and (0 OR condition 2) logical operation how to understand?
Recently encountered such a problem, is about the logical operation, see:
Condition 1 and (0 OR condition 2)
If there is no keyword, then the latter part is (0)
Condition 1 and (0), that is not true, no query results returned, no input keywords.
If there is, then:
Condition 1 and (0 OR condition 2)
is actually
Condition 1 and (condition 2)
I have written a test code:
$a = 3;
$b = 0;
if ($a and (1 OR $b))
{
Print $a. $b;
}
Else
{
Print "false";
}
?>
I write the above and (0 or $b) intentionally into and (1 or $b)) and the test results are as follows:
30
A netizen pointed out that and (1 and $b)) or and (0 or $b)), when the condition is and, the front plus 1, when the condition is OR, plus 0 will not affect the result set.
But I deliberately write the opposite, the results of the test 30, for this expression still do not understand, also do not know where the idea card, of course, if written in $ A and (0 OR $b) will be output false, because only one side value is true, but still do not understand the difference is where, everyone give twos good? Thank you so much.

------Solution--------------------
1and$b need two conditions are set up
1or$b because it has been judged that the front is 1, and the back is not judged
0or$b Front is O is not established, so continue to judge whether $b is established.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.