PHP's three types of operators
An operator is something that can produce another value (and thus the entire structure as an expression) by giving one or more of the values (in programming jargon, expressions).
The first is a unary operator, and only one value is calculated, for example! (Take the inverse operator) or + + (plus one operator).
Example
1, the use of ++i (take A=++i, i=2 as an example)
The I value is first added to 1 (that is, i=i+1) and then assigned to the variable a (that is, a=i),
Then the final a value is equal to 3, and the I value equals 3.
So a=++i equivalent to i=i+1, a=i
2, the use of i++ (take a=i++, i=2 as an example)
First assign the I value to the variable a (that is, a=i), then I value 1 (that is, i=i+1),
Then the final a value is equal to 2, and the I value equals 3.
So a=i++ equivalent to A=i, i=i+1
3, ++i and i++
A=++i equivalent to i++, a=i
a=i++ equivalent to A=i, i++
4, ++i and i++ when used alone, equivalent to I=i+1
If you assign a new variable, the ++i first adds 1 to the I value, and the i++ first assigns I to the new variable
The second is the two-tuple operator, which accepts two values, such as the familiar arithmetic operator + (plus) and-(minus), and most of the PHP operators are this
$a =1+2;
$b = 3-1;
The third is the ternary operator, which accepts three values, which should be used to select one of the two expressions based on an expression, rather than a two statement or a program route. (also known as the conditional operator may be more appropriate)
The code format is as follows: (EXPR1)? (EXPR2): (EXPR3);
For example: $page =!empty ($_get[' page ')? $_get[' page ': 1;
http://www.bkjia.com/PHPjc/895547.html www.bkjia.com true http://www.bkjia.com/PHPjc/895547.html techarticle The three types of operator operators in PHP are the east that can produce another value (thus the entire structure becomes an expression) by giving one or more values (in programming jargon, expressions) ...