PHP Operators
Operators are used to performing operations on variables and values.

PHP divides the operators into the following groups:
- Arithmetic operators
- Assignment operators
- Comparison operators
- Increment/Decrement operators
- Logical operators
- String operators
- Array operators
This chapter shows the different operators that can be used in PHP scripts.
PHP Arithmetic Operators
The example below shows the different results of using the different arithmetic operators:
| Operator | Name | Example | Result |
|---|---|---|---|
| + | Addition | $x + $y | Sum of $x and $y |
| - | Subtraction | $x - $y | Difference of $x and $y |
| * | Multiplication | $x * $y | Product of $x and $y |
| / | Division | $x / $y | Quotient of $x and $y |
| % | Modulus | $x % $y | Remainder of $x divided by $y |
| ** | Exponentiation | $x ** $y | Result of raising $x to the $y'th power (Introduced in PHP 5.6) |
Example
<?php
$x=8;
$y=4;
echo ($x + $y); // outputs 12
echo ($x - $y); // outputs 4
echo ($x * $y); // outputs 32
echo ($x / $y); // outputs 2
echo ($x % $y); // outputs 2
?>
