PHP Arithmetic Operators
The arithmetic operators are operators we see commonly in everyday use. Apart from arithmetic negation and arithmetic assertion operators, most Arithmetic operators are binary.
PHP provides plenty of mathematical functions for basic calculations and conversions, calculating logarithms, square roots, geometric values, etc.
Numeric operators take integer or floating-point arguments and compute a result on them. Both left and right arguments to an operator have the same numeric type (integer or floating-point). Still, it is possible to mix these, putting an integer on the left side and floating-point on the right side or the other way around. These operators require numeric values, and non-numeric values are converted into numeric values.
Arithmetic operators combine operands consisting of one or more variables and constants. Arithmetic operators supported by PHP are addition(+),subtraction(-),multiplication(*),division(/) and modulus(%).
|+||Addition||$m * $n||Return the sum of both operands |
|–||Substration||$m – $n||Return the difference of both operands |
|*||Multiplication||$m * $n||Return the product of both operands |
|/||Division||$m / $n||Return the quotient of both operands |
|%||Modulo||$m % $n||Return the remainder of both operands |
|**||Exponentiation||$m ** $n||Return the result of both operands raising |
PHP - Addition Operator(+)
Both operands are added and returned as output.
PHP - Subtraction Operator(-)
Subtracts both operands and returns as output.
PHP - Multiplication Operator(*)
Multiplies both operands and returns as output.
PHP - Division Operator(/)
Divides numerator by denominator and returns as output.
PHP - Modulus Operator(%)
Returns the remainder after the division of the operands.