I. PHP has a rich set of operators, most of which are directly from the C language. Operators can be divided into arithmetic operators, string operators, value assignment operators, bitwise operators, conditional operators, and logical operators. When various operators are in the same
I. PHP operators
PHP has a rich set of operators, most of which are directly from the C language. Operators can be divided into arithmetic operators, string operators, value assignment operators, bitwise operators, conditional operators, and logical operators. When operators are in the same expression, their operations have a certain priority.
(1) arithmetic operations
+-*/% + + --
(2) string operators
The character string operator has only one. (point), which is an English ending. It can connect a string to form a new string, or connect a string to a number. the type is automatically converted.
$ A = "dawanganban"; $ B = "123"; echo $ a. $ B; // output result: dawanganban123
(3) value assignment operator
= + =-= * =/= % =. =
$ A = "dawanganban"; $ a. = 1; $ a. = 2; $ a. = 3; echo $ a. $ B; // output result: dawanganban123
(4) bitwise operators
& | ~ ^ <>
(5) comparison operators
><>==! = <>==! =
<>: Not equal to or! = Same
===: Constant, equal value and consistent type
! ==: Non-constant, with inconsistent values or types
Echo 5 = "5"; // true PHP is a weak language (variables in js are similar) echo 5 = "5"; // false is completely equal
(6) logical operations
AND (logical AND) OR (logical OR) XOR (logical OR )&&(Logic and)|(Logical OR)! (Non-logical)
var_dump(5 && ""); //falsevar_dump(5 && "2"); //truevar_dump(5 || ""); //truevar_dump(0 xor 1); //truevar_dump(0 xor 0); //falsevar_dump(1 xor 1); //false
2. Process control
(1) if... else...
if(boolean){//TODO}
if(boolean){//TODO}else{//TODO}
if(boolean){//TODO}elseif(boolean){//TODO}elseif(boolean){//TODO}else{//TODO}
(2) switch
switch(expr){case expr1://TODObreak;case expr2://TODObreak;default://TODO}
(3) while loop
while(boolean){//TODOif(boolean) continue;if(boolean) break;}
(4) for loop
Break n; n indicates the number of bounce layers. the default value is 1.
Continum; indicates skipping a loop.