What are the arithmetic operators in PHP?

Arithmetic operators are used to do maths on numbers. PHP has these arithmetic operators:

OperatorNameExampleResult
+Addition10 + 313
–Subtraction10 – 37
*Multiplication10 * 330
/Division10 / 33.3333333333333
%Modulus (remainder)10 % 31
**Exponentiation (power)10 ** 31000
<?php
$a = 10;
$b = 3;

echo ($a + $b) . "<br>";
echo ($a - $b) . "<br>";
echo ($a * $b) . "<br>";
echo ($a / $b) . "<br>";
echo ($a % $b) . "<br>";
echo ($a ** $b);
?>

Output:

Tutorials Class - Output Window

13
7
30
3.3333333333333
1
1000

Division always gives a float when the result is not a whole number. Use intdiv() if you need only the whole part. Read all operators in PHP Operators.


Learn more about the similar topics:
Tutorials
PHP Operators
PHP Ternary Operator
Exercises & Assignments
Write a PHP program to add two numbers
Interview Questions & Answers
What is the difference between == and === Operators in PHP?
What are the arithmetic operators in PHP?
What is the use of the ternary operator in PHP?
What is the null coalescing operator (??) in PHP?
What is the difference between division (/) and modulus (%) in PHP?
What is the difference between != and !== in PHP?
What is the difference between $var++ and $var + 1 in PHP?