Operator is the basic content that will be used in any development language, let me introduce some of the basics of PHP operators and how to use them.
Operator is used to operate on a value.
PHP operators
This section lists the various operators used in PHP:
Arithmetic operators
| operator |
Description |
Example |
Results |
| + |
Addition |
x=2 X+2 |
4 |
| - |
Subtraction |
x=2 5-x |
3 |
| * |
Multiplication |
X=4 X*5 |
20 |
| / |
Division |
15/5 5/2 |
3 2.5 |
| % |
Modulus (Division remainder) |
5%2 10%8 10%2 |
1 2 0 |
| ++ |
Increment |
X=5 X + + |
X=6 |
| – |
Decrement |
X=5 X – |
X=4 |
Assignment operators
| operator |
Description |
Example |
| = |
X=y |
X=y |
| += |
X+=y |
X=x+y |
| -= |
X-=y |
X=x-y |
| *= |
X*=y |
X=x*y |
| /= |
X/=y |
x=x/y |
| .= |
X.=y |
X=x.y |
| %= |
X%=y |
X=x%y |
Comparison operators
| operator |
Description |
Example |
| == |
is equal to |
5==8 returns False |
| != |
is not equal |
5!=8 returns True |
| > |
is greater than |
5>8 returns False |
| < |
is less than |
5<8 returns True |
| >= |
is greater than or equal to |
5>=8 returns False |
| <= |
is less than or equal to |
5<=8 returns True |
logical operators
| operator |
Description |
Example |
| && |
and |
X=6 Y=3 (x < ten && y > 1) returns True |
| || |
Or |
X=6 Y=3 (x==5 | | y==5) returns false |
| ! |
Not |
X=6 y=3! (x==y) returns True |
http://www.bkjia.com/PHPjc/628648.html www.bkjia.com true http://www.bkjia.com/PHPjc/628648.html techarticle operator is the basic content that will be used in any development language, let me introduce some of the basics of PHP operators and how to use them. Operator is used to operate on a value. PHP operator ...