Name
|
Operator
|
What does it do?
|
Example
|
---|---|---|---|
Addition
|
+ |
It is used to perform normal addition.
|
$a + $b
|
Subtraction
|
- |
It is used to perform normal subtraction.
|
$a - $b
|
Multiplication
|
* |
It is used to perform multiplication.
|
$a * $b
|
Division
|
/ |
It is used to perform division.
|
$a / $b
|
Exponent
|
** |
It returns the first operand raised to the power the second operand.
$a ** $b = $a$b |
$a ** $b
|
Modulus(or, Remainder)
|
% |
It returns the remainder of first operand divided by the second operand
|
$a % $b
|
Operator
|
Usage
|
---|---|
= |
$a = $b , will save the value of variable $b to the variable $a |
+- |
$a += $b is same as $a + $b |
-= |
$a -= $b is same as $a - $b |
*= |
$a *= $b is same as $a * $b |
/= |
$a /= $b is same as $a / $b |
%= |
$a %= $b is same as $a % $b |
Name
|
Operator
|
What does it do?
|
Example
|
---|---|---|---|
Equal
|
== |
It returns
true if left operand is equal to the right operand. |
$a == $b
|
Identical
|
=== |
It returns
true if left operand is equal to the right operand and they are of the same type. |
$a === $b
|
Not Equal
|
!= |
It returns
true if left operand is not equal to the right operand. |
$a != $b
|
Not Identical
|
!== |
It returns
true if left operand is not equal to the right operand, and they are of different type as well. |
$a !== $b
|
Greater than
|
> |
It returns
true if left operand is greater than the right operand. |
$a > $b
|
Less than
|
< |
It returns
true if left operand is less than the right operand. |
$a < $b
|
Greater than or equal to
|
>= |
It returns
true if left operand is greater than or equal to the right operand. |
$a >= $b
|
Less than or equal to
|
<= |
It returns
true if left operand is less than or equal to the right operand. |
$a <= $b
|
Operator
|
Usage
|
---|---|
++$a |
Pre Increment, It will first increment the operand by
1 (add one to it) and then use it or return it. |
$a++ |
Post Increment, It will first return the operand and then increment the operand by
1 . |
--$b |
Pre Decrement, It will first decrement the operand by
1 (subtract one from it) and then use it or return it. |
$b-- |
Post Decrement, It will first return the operand and then decrement the operand by
1 . |
Operator
|
Name
|
Example
|
Result
|
and
|
And
|
$a and $b
|
True if both $a and $b are true
|
or
|
Or
|
$a or $b
|
True if either $a or $b is true
|
xor
|
Xor
|
$a xor $b
|
True if either $a or $b is true, but not both
|
&&
|
And
|
$a && $b
|
True if both $a and $b are true
|
||
|
Or
|
$a || $b
|
True if either $$a or $b is true
|
!
|
Not
|
!$a
|
True if $a is not true
|
Name
|
Operator
|
What does it do?
|
Example
|
---|---|---|---|
Concatenation
|
. (a dot) |
It is used to concatenate(join together) two strings.
|
$a.$b
|
Concatenation Assignment
|
.= |
It is used to append one string to another.
|
$a .= $b
|
Operator
|
Name
|
Example
|
Result
|
+
|
Union
|
$a + $b
|
Union of $a and $b
|
==
|
Equality
|
$a == $b
|
True if $a and $b have the same key/value pairs
|
===
|
Identity
|
$a === $b
|
True if $a and $b have the same key/value pairs in the same order and of the same types
|
!=
|
Inequality
|
$a != $b
|
True if $a is not equal to $b
|
<>
|
Inequality
|
$a <> $b
|
True if $a is not equal to $b
|
!==
|
Non-identity
|
$a !== $b
|
True if $a is not identical to $b
|