PHP Operator is a symbol that tells the PHP processor to do certain actions. There are several operators used in PHP language, so we have separated them into the following categories to create it easier to learn them all.
In PHP have following operators, please see below point wise:
- Arithmatic Operators
- Assignment Operators
- Comparison Operators
- Increment/Decrement Operators
- Logical Operators
- String Operators
- Array Operators
a) ARITHMATIC OPERATORSPHP arithmetic operators used for numeric values to perform arithmetical operations, like addition, subtraction, multiplication, division, modulus etc.
Like: $a + $b, $a - $b, $a * $b, $a / $b, $a % $b
b) ASSIGNMENT OPERATORSAssignment operator in PHP is "=". It means the left operand gets set the value of the assignment expression on the right.
|A = B + C will assign value of B + C into A|
|A += B is equivalent to A = A + B||(Addition) |
|A -= B same as A = A - B||(Substraction)|
|A *= B same as A = A * B||(Multiplication)|
|A /=B same as A = A / B||(Division)|
|A %=B same as A = A % B||(Modulus)|
c) COMPARISON OPERATORSPHP comparison are compare to two values !!
|Operator ||Name of Operator||Example|
|==||Equal||$a == $b|
|!=||Not equal||$a != $b|
|<>||Not equal||$a <> $b|
|>||Greater than||$a > $b|
|<||Less than||$a <$b|
|>=||Greater than or equal to||$a >= $b|
|<=||Less than or equal to||$a <= $b|