PHP operator basics tutorial. Operators are the basic content used in any development language. next I will introduce some basic knowledge and usage of PHP operators. The PHP operator is the basic content used in any development language. next I will introduce some basic knowledge and usage of the PHP operator.
The operator is used to calculate the value.
PHP operators
This section lists various operators used in PHP:
Arithmetic operators
Operator |
Description |
Example |
Result |
+ |
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 (pision remainder) |
5% 2 10% 8 10% 2 |
1 2 0 |
++ |
Increment |
X = 5 X ++ |
X = 6 |
- |
Decrement |
X = 5 X- |
X = 4 |
Value assignment operator
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 |
5 = 8 returns false |
! = |
Is not equal |
5! = 8 returns true |
> |
Is greater |
5> 8 returns false |
< |
Is less |
5 <8 returns true |
> = |
Is greater than or equal |
5> = 8 returns false |
<= |
Is less than or equal |
5 <= 8 returns true |
Logical operators
Operator |
Description |
Example |
&& |
And |
X = 6 Y = 3 (x <10 & y> 1) returns true |
| |
Or |
X = 6 Y = 3 (x = 5 | y = 5) returns false |
! |
Not |
X = 6 Y = 3! (X = y) returns true |
Bytes. Operator is used to calculate the value. PHP operator...