With PHP's familiar arithmetic operators, adding, subtraction, multiplication, division, exponentiation, and modulus are all possible.
The arithmetic operators require numeric values. When you employ an arithmetic operator on a non-numeric value, it first transforms it to a numeric value before doing the calculation.
| Operator | Name | Example | Description |
|---|---|---|---|
| + | Addition | $x * $y | Get the total of $x and $y. |
| - | Subtraction | $x – $y | Calculate the difference between $x and $y. |
| * | Multiplication | $x * $y | Return the $x and $y product. |
| / | Division | $x / $y | Return the $x and $y quotient. |
| % | Modulo | $x % $y | Return $x divided by $y as a remainder. |
| ** | Exponentiation | $x ** $y | Raise $x to the $y'th power and return the result. |
The arithmetic operators are used in the following example:
|
|