PHP Operators are used to perform operations on operands. Operands can be a variable or a constant. The operators are divided into various groups on the basis of the basic operations they perform.

**Arithmetic Operators:**** **

The operators which are used to perform the arithmetical operations, are grouped together as Arithmetic operators.

Operators |
Symbol |

Addition | + |

Subtraction | – |

Multiplication | * |

Division | / |

Modulus | % |

Exponentiation | ** |

**Assignment Operators:**** **

The operators which are used to assign values to a variable, are grouped together as Assignment operators.

Operators |
Symbol |

Equals To | = |

Added Value | += |

Subtracted Value | -= |

Multiplicated Value | *= |

Divided Value | /= |

Modulus Value | %= |

**Comparison Operators:**** **

The operators which are used to compare two values, are grouped together as Comparison operators.

Operators |
Symbol |

Equal | == |

Identical | === |

Not equal | !=, <> |

Not identical | !== |

Greater than | > |

Less than | < |

Greater than or equal to | >= |

Less than or equal to | <= |

**Increment/ Decrement Operators:**** **

The operators which are used to increment or decrement the value of a variable, are grouped together as Increment and Decrement operators.

Operators |
Symbol |

Pre-Increment | ++$x |

Post-Increment | $x++ |

Pre-Decrement | –$x |

Post-Decrement | $x– |

**Logical Operators:**** **

The operators which are used to perform logical operations, are grouped together as Logical operators.

Operators |
Symbol |

AND | And, && |

OR | Or, || |

XOR | xor |

NOT | ! |

**String Operators:**** **

The operators which are used to perform operations on string, are grouped together as String operators.

Operators |
Symbol |

Concatenation | . |

Concatenation assignment | .= |

**Array Operators:**** **

The operators which are used to perform operations on array, are grouped together as Array operators.

Operators |
Symbol |

Union | + |

Equality | == |

Identity | === |

Inequality | !=, <> |

Non-Identity | !== |

**Example:**

<!DOCTYPE html> <html> <body> <?php $txt1 = "Sum of 1234 and 4321 is:"; $txt2 = “Difference of 1234 and 4321 is:"; $txt3 = “Product of 1234 and 4321 is:"; $txt4 = “Quotient of 1234 and 4321 is:"; $x = 1234; $y = 4321; echo "<h3>" . $txt1 . "</h3>"; echo $x + $y; echo "<h3>" . $txt2 . "</h3>"; echo $x - $y; echo "<h3>" . $txt3 . "</h3>"; echo $x * $y; echo "<h3>" . $txt4 . "</h3>"; echo $x / $y; ?> </body> </html> |