Basic PHP syntax (2) VII. PHP operator 1. arithmetic operator description + plus-minus * multiplication and division % modulo 2. Assignment operator value assignment is equivalent to the description of the right expression of xyxy to set the value of the left Operation number. X + yxx + y + x-yxx-y minus the basic syntax of x * yxx * y PHP (2)
VII. PHP operator 1. arithmetic operator
| Arithmetic |
Description |
| + |
Add |
| - |
Subtraction |
| * |
Multiplication |
| / |
Division |
| % |
Modulo |
2. value assignment operator
| Assignment |
Equivalent |
Description |
| X = y |
X = y |
The expression on the right sets the value for the number of operations on the left. |
| X + = y |
X = x + y |
Add |
| X-= y |
X = x-y |
Subtraction |
| X * = y |
X = x * y |
Multiplication |
| X/= y |
X = x/y |
Division |
| X % = y |
X = x % y |
Module |
3. string operators
| Operator |
Name |
Example |
Result |
| . |
Concatenation |
$ Txt1 = "Hello" $ txt2 = $ txt1. "world !" |
Now $ txt2 contains "Hello world !" |
| . = |
Serial assignment |
$ Txt1 = "Hello" $ txt1. = "world !" |
Now $ txt1 contains "Hello world !" |
4. increment/decrease operator
| Operator |
Name |
Description |
| ++ $ X |
Ascending |
$ X increment by one, and then returns $ x |
| $ X ++ |
Post-increment |
Returns $ x, and increments by $ x plus one. |
| -$ X |
Decrease before |
$ X Minus One decrease, and then returns $ x |
| $ X- |
Decrease |
Returns $ x, and then decreases by $ x. |
5. Comparison operators
| Operator |
Name |
Example |
Result |
| = |
Equal |
$ X = $ y |
Returns true if $ x is equal to $ y. |
| === |
Equality (identical) |
$ X ===$ y |
Returns true if $ x is equal to $ y and has the same type. |
| ! = |
Not equal |
$ X! = $ Y |
Returns true if $ x is not equal to $ y. |
| <> |
Not equal |
$ X <> $ y |
Returns true if $ x is not equal to $ y. |
| ! = |
Incomplete (completely different) |
$ X! ==$ Y |
If $ x is not equal to $ y and their types are different, true is returned. |
| > |
Greater |
$ X> $ y |
If $ x is greater than $ y, true is returned. |
| < |
Greater |
$ X <$ y |
If $ x is less than $ y, true is returned. |
| > = |
Greater than or equal |
$ X> = $ y |
Returns true if $ x is greater than or equal to $ y. |
| <= |
Less than or equal |
$ X <= $ y |
If $ x is less than or equal to $ y, true is returned. |
6. logical operators
| Operator |
Name |
Example |
Result |
| And |
And |
$ X and $ y |
If both $ x and $ y are true, true is returned. |
| Or |
Or |
$ X or $ y |
If either $ x or $ y is true, true is returned. |
| Xor |
Exclusive or |
$ X xor $ y |
If $ x and $ y have only one of them, true is returned. |
| && |
And |
$ X & $ y |
If both $ x and $ y are true, true is returned. |
| | |
Or |
$ X | $ y |
If either $ x or $ y is true, true is returned. |
| ! |
Non |
! $ X |
Returns true if $ x is not true. |
7. array operators
| Operator |
Name |
Example |
Result |
| + |
Union |
$ X + $ y |
$ X and $ y (but do not overwrite duplicate keys) |
| = |
Equal |
$ X = $ y |
Returns true if $ x and $ y have the same key/value pair. |
| === |
Full |
$ X ===$ y |
True is returned if $ x and $ y have the same key/value pairs with the same sequence and type. |
| ! = |
Not Equal |
$ X! = $ Y |
Returns true if $ x is not equal to $ y. |
| <> |
Not Equal |
$ X <> $ y |
Returns true if $ x is not equal to $ y. |
| ! = |
Incomplete |
$ X! ==$ Y |
Returns true if $ x is different from $ y. |
Copyright Disclaimer: This article is an original Lshare article. if you need to reprint it, please contact me. if you have any questions, please comments or private messages.