In-depth PHP logic operations

Source: Internet
Author: User
<? PHP/* logic and operation */$ A = 1; if (false & $ A ++) echo $ A; else echo $ A; // output 1, because the first condition is false, the logical expression returns false directly, so $ A ++ does not execute $ A = 1; if (true & $ A ++) echo $; // output 2, the first condition is true, so the expression $ A ++, $ A ++ returns 1, and then $ A plus 1 equals 2, the logical operation between true and 1 is true, and the output $ A is 2 $ A = 0; If (true & $ A ++) echo 'OK'; else echo $; // Output 1. The first condition is true, so $ A ++ is judged. This expression returns the value 0 of $ A, and then $ A plus 1 equals 1, the logical operation between true and 0 is false. The value of $ A in else output is 1?> Or is used to determine the first condition first. If the first condition is true, the logical expression returns true directly without judging the second condition.

 

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.