How to understand the logical operation of this condition 1AND (0OR condition 2)

Source: Internet
Author: User
What is the logical operation of this condition 1AND (0OR condition 2? We encountered such a problem recently. for details about logical operations, see Condition 1 & nbsp; AND & nbsp; (& nbsp; 0 & nbsp; OR & nbsp; condition 2) if there is no keyword, the following part is (0) condition 1 & nbsp; AND & nbsp; (& nbsp; 0), that is, it is not true, what is the logical operation of condition 1 AND (0 OR condition 2?
Recently, we encountered such a problem about logical operations. please refer:
Condition 1 AND (0 OR condition 2)
If no keyword exists, the following part is (0)
Condition 1 AND (0) is not true. no query results are returned, AND no keywords are entered.
If yes, then:
Condition 1 AND (0 OR condition 2)
Actually
Condition 1 AND (condition 2)
I wrote a test code:
$ A = 3;
$ B = 0;
If ($ a and (1 OR $ B ))
{
Print $ a. $ B;
}
Else
{
Print "false ";
}
?>
I intentionally wrote the and (0 OR $ B) above as and (1 OR $ B). the test results are as follows:
30
Some netizens pointed out that and (1 and $ B) OR and (0 OR $ B). when the condition is "AND", add 1 to the front, if the condition is OR, adding 0 does not affect the result set.
But I intentionally wrote the opposite, and got the test result 30. I still don't know the expression, and I don't know where the idea is. of course, if it is written in $ a and (0 OR $ B), false will be output, because only one side of the value is true, but I still don't know where the difference is. can you give me some advice? Thank you.

------ Solution --------------------
1and $ B requires both conditions to be true.
1or $ B because we have determined that the previous one is true, the latter is not true.
0 or $ B is not true before o, so continue to judge whether $ B is true.

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.