# PHP operators – Arithmetic, Logical, Comparison and Assignment

To perform any calculation or process the data, you need operands and PHP operators. Operands are the constants or variables on which you wish to perform operation. Operators are the symbols that represent the operation. PHP operators are classified as Arithmetic, Logical, Comparison, Assignment and  String operators.

## PHP operators

### Arithmetic operators

These operators are used for performing basic arithmetic operations on numeric values or variables.

 Operator Operation Performed + Returns sum  of two numeric values – Returns difference of two numeric values * Returns product of two numeric values / Returns quotient after division of first number by second % Returns remainder after division of first number by second

### Comparison operators

These operators are used for comparing values to be used in conditional or looping constructs.

 Operator Operation Performed == Compares equality of two values returns true if equal else false != Compares inequality of two values returns true if unequal else false > Compares  two values returns true if left hand side value is greater than the right hand side value else false >= Compares  two values returns true if left hand side value is greater than or equal to the right hand side value else false < Compares  two values returns true if left hand side value is less than the right hand side value else false <= Compares  two values returns true if left hand side value is less than or equal to the right hand side value else false === Compares  two values returns true if left hand side value is equal to right hand side value and both are of same data type else false

### Logical operators

These PHP operators are used to combine conditions in conditional or looping constructs.

 Operator Operation Performed && Represents logical AND. Returns true only if all the individual expressions having  comparison operators are true || Represents logical OR. Returns true even if a single expression having comparison operator is true ! Represents logical NOT. Returns true if the expression is false and returns false if the expression is true

### Assignment operators

These operators are used perform the operation between left hand side operand and right hand side operand and return the result to left hand side variable.

 Operator Operation Performed += Performs sum of left hand side and right hand side values and assign result to left hand side variable -= Performs subtraction of left hand side and right hand side values and assign result to left hand side variable *= Performs multiplication of left hand side and right hand side values and assign result to left hand side variable /= Performs division  of left hand side value with right hand side and assign result to left hand side variable %= Performs modulus(remainder) of left hand side value with right hand side value and assign result to left hand side variable ++ Increments the value of variable by 1 — Decrements the value of variable by 1