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 Henan Medical Hospital Affiliated Hospital
= += -= *= /= %= .=
$a = "Dawanganban";
$a. =1;
$a. =2;
$a. =3;
echo $a. $b; Output Result: dawanganban123
(4) Bitwise operator
& | ~ ^ << >>
(5) comparison operator
> < >= <= = = = = = = = =!==
<>: Not equal to and! = Same
= = =: Identical, value equal and type consistent
! = =: Non-identical, value not equal or type inconsistent
echo 5 = = "5";//true PHP is a weakly typed language (variable in JS)
echo 5 = = = 5 ";//false exactly equals
(6) Logical Operation
A ND (logical VS) 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