PHP Mobile internet Developer's operator

Source: Internet
Author: User
Tags bitwise bitwise operators php operator
[Introduction] PHP operator PHP has a rich set of operators, most of them directly from the C language. Depending on the function, operators can be divided into: arithmetic operators, string operators, assignment operators, bitwise operators, conditional operators, and logical operators. When the various operators are in the same

PHP has a rich set of operators, most of which come directly from the C language. Depending on the function, operators can be divided into: arithmetic operators, string operators, assignment operators, bitwise operators, conditional operators, and logical operators. When the various operators are in the same expression, their operations have a certain precedence.

(1) Arithmetic operations

+ - * / % ++ --

(2) String operators

There is only one string operator. (dot) is the end of the English period. It can concatenate strings together, form new strings, or concatenate strings to numbers, and the type will automatically convert.

$a = "Dawanganban";  $b = "123";  echo $a. $b;   Output Result: dawanganban123

(3) Assignment operator

= + = = *=/=%=. = $a = "Dawanganban";  $a. =1;  $a. =2;  $a. =3;  echo $a. $b;   Output Result: dawanganban123

(4) Bitwise operator

& | ~ ^ << >>

(5) Comparison operators

> < >= <= = = = = <> = = =!==

<>: Not equal to and! = Same

= = =: Identical, values equal and type consistent

! = =: Non-identical, value not equal or type inconsistent

    1. echo 5 = = "5"; True  PHP is a weakly typed language (the variable in JS is similar)  echo 5 = = = "5";  False is  exactly equal to

(6) Logical operation

and (Logical AND) or (logical OR) XOR (logical XOR) && (logic and) | | (Logical OR)! (Logical non)

Var_dump (5 && "");   False  Var_dump (5 && "2");//true  var_dump (5 | | ""); True  var_dump (0 xor 1);//true  var_dump (0 xor 0);//false  Var_dump (1 xor 1);//false

First, the PHP operator

PHP has a rich set of operators, most of which come directly from the C language. Depending on the function, operators can be divided into: arithmetic operators, string operators, assignment operators, bitwise operators, conditional operators, and logical operators. When the various operators are in the same expression, their operations have a certain precedence.

(1) Arithmetic operations

+ - * / % ++ --

(2) String operators

There is only one string operator. (dot) is the end of the English period. It can concatenate strings together, form new strings, or concatenate strings to numbers, and the type will automatically convert.

$a = "Dawanganban";  $b = "123";  echo $a. $b;   Output Result: dawanganban123
(3) Assignment operator

= + = = *=/=%=. = $a = "Dawanganban";  $a. =1;  $a. =2;  $a. =3;  echo $a. $b;   Output Result: dawanganban123
(4) Bitwise operator

& | ~ ^ << >>

(5) Comparison operators

> < >= <= = = = = <> = = =!==

<>: Not equal to and! = Same

= = =: Identical, values equal and type consistent

! = =: Non-identical, value not equal or type inconsistent

    1. echo 5 = = "5"; True  PHP is a weakly typed language (the variable in JS is similar)  echo 5 = = = "5";  False is  exactly equal to

(6) Logical operation

and (Logical AND) or (logical OR) XOR (logical XOR) && (logic and) | | (Logical OR)! (Logical non)

Var_dump (5 && "");   False  Var_dump (5 && "2");//true  var_dump (5 | | ""); True  var_dump (0 xor 1);//true  var_dump (0 xor 0);//false  Var_dump (1 xor 1);//false

Related Article

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.