The most common PHP operators are assignment operators, arithmetic operators, combined operators, comparison operators, and logical operators. Each type is discussed separately below.
Assignment Operators
The basic assignment operator in PHP is "=". This means that the operand to the left of "=" gets set to the value to the right of "=".
Arithmetic Operators
Operator | Example | Result |
+ | 4 + 2 | 6 |
- | 4 - 2 | 2 |
* | 4 * 2 | 8 |
/ | 4 / 2 | 2 |
% | 4 % 2 | 0 |
++ | x = 4; x++; | x = 5 |
-- | x = 4; x--; | x = 3 |
Combined Operators
You can combine an arithmetic operator with the assignment operator to form a combined operator. Combined operators are shown below:
Operator | Example | Meaning |
+= | y += x | y = y + x |
-= | y -= x | y = y - x |
*= | y *= x | y = y * x |
/= | y /= x | y = y / x |
%= | y %= x | y = y % x |
Comparison Operators
Operator | Meaning |
== | is equal to |
!= | is not equal to |
> | is greater than |
>= | is greater than or equal to |
< | is less than |
<= | is less than or equal to |
Logical Operators
Operator | Meaning |
|| | or |
&& | and |
and | and |
or | or |
xor | xor |
! | not |
If you like this please Link Back to this article...
0 comments:
Post a Comment