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