Php operators and short-circuit Operators

Source: Internet
Author: User
1. Comparison operators only judge whether they are equal, all are equal, and the judgment and type! It's just that the judgment is not equal ,! The value is not equal to the value of Type 2. logical xor or xor: True 3. bitwise operator (compared using binary): bitwise AND: All 1 is 1, otherwise 0 is bitwise OR: | all 0 is 0, if the value is 1, the value is equal to or equal to ^.

1. comparison operator ==only determines whether it is equal, === all equals, judgment and type! = It's just that the results are not equal ,! = Not all equal, judgment must also determine the type 2. logical xor or xor: True 3. bitwise operator (compared using binary): bitwise AND: All 1 is 1, otherwise 0 is bitwise OR: | all 0 is 0, if the value is 1, the value is equal to or equal to ^.

1. Comparison Operators

==Only judge whether the value is equal, ==== all equals, the judgment value and type

! = Only judge that the values are not equal ,! = Not all equal, the judgment value must also determine the type


2. Logic exclusive or

Xor: True

3. bitwise operators (compared using binary ):

Bitwise AND: & all 1 is 1, otherwise it is 0

By bit or: | all 0 is 0, no is 1

Returns 0 if it is equal to the bitwise OR: ^. Otherwise, the value is 1.

By-bit non :~ 1 to 0 to 1

4. Displacement operators:

Left shift: shifts to the left, with less than 0 on the right: for example, $ a <1 shifted to the left

Right Shift: shifts to the right. If the left side is not enough, add 0. For example, $ a> 1 to the right.

5. Join operators:

. Connect two parameters to generate a new string

. = Append the value on the right to the left. It is a string-like connection, and the same is true for numbers.

@ Do not use warning information. It can be placed before functions, variables, and constants to disable displaying error warning information.

6. Short Circuit of the operator:

Only a short circuit exists between logic and logic.

$ A = 1;

$ A = 1 | $ c = 100;

Echo $ c; // short-circuited, $ c is not assigned a value, and the logic ends if either of them is true.

$ A = 1;

$ A = 2 & $ c = 100;

Echo $ c; // short-circuited, $ c is not assigned a value, and the logic ends when either of them is false.

A short circuit is used to determine whether the read file exists:

@ Fopen ("xxx.txt") or die ("file does not exist ");

After the die command is used to output text, the script after the die will not run and the program will be terminated.

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.