Three types of PHP Operators
An operator can generate another value (thus the entire structure becomes an expression) by giving one or more values.
The first type is the unary operator, which calculates only one value, for example! (Inverse Operator) or ++ (plus one operator ).
Example
1. Usage of ++ I (using a = ++ I, I = 2 as an example)
Add the I value to 1 (that is, I = I + 1) and then assign it to variable a (that is, a = I ),
The final a value is 3, and the I value is 3.
So a = ++ I is equivalent to I = I + 1, a = I
2. I ++ usage (take a = I ++, I = 2 as an example)
First, assign the I value to variable a (that is, a = I), and then add 1 (that is, I = I + 1) to the I value ),
Then, the final a value is 2, and the I value is 3.
So a = I ++ is equivalent to a = I, I = I + 1
3. ++ I and I ++
A = ++ I is equivalent to I ++, a = I
A = I ++ is equivalent to a = I, I ++
4. When ++ I and I ++ are used independently, they are equivalent to I = I + 1.
If a new variable is assigned, ++ I first adds 1 to the I value, and I ++ first assigns I to the new variable.
The second type is binary operators, which can accept two values, such as the familiar Arithmetic Operators + (plus) and-(minus). Most PHP operators use this type.
$ A = 1 + 2;
$ B = 3-1;
The third is the ternary operator, which can accept three values. It should be used to select one of the other two expressions based on one expression, rather than in two statements or program routes. (It can also be called conditional operators)
The code format is as follows: (expr1 )? (Expr2): (expr3 );
Example: $ page =! Empty ($ _ GET ['page'])? $ _ GET ['page']: 1;