4. Operators (4) logical operators

Source: Internet
Author: User
Objective: To Learn logical operators: Understand logical operators and use them (& | ). <? PHP // if you have a female requirement and a house or a car, you will be married. $ House = false; $ car = false; if ($ House = true) {if ($ car = true) {echo 'true love ';} else {echo 'gun' ;}} else {echo 'gun'; // analysis code: when the first value of 'gun' is false, it is finished directly .. } Echo '<br/>'; $ House = true; $ car = true; if ($ House = true & $ car = true) {// analysis: Use the '&' logical operator to determine 'and' must meet two conditions to be true. Echo 'I love you', '<br/>';} else {echo 'has a bad character.} // if you have a female requirement, you can marry a room just like a car. $ House = true; $ car = false; if ($ House = true | $ car = true) {// analysis: use the '|' logical operator to determine 'or' if only one record is satisfied, it can be true echo 'cheap you';} else {echo 'Nice of you ';}?> * When | after logical judgment, the first expression is true, and the latter is not judged. Similarly, the first item to be judged with "&" is false and will not be followed by the judgment.

4. Operators (4) logical operators

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.