This tutorial presents an example of the use of PHP arithmetic operators. The primary purpose of this example program is to explain to beginners how arithmetic operations perform in PHP.

In this example program, all the five arithmetic operators have been used to perform various calculations such as addition, subtraction, multiplication, division, and modulus operations.

Example:

PHP script to demonstrate arithmetic operations:

<?php
/* Variable definition and assignment */
$a=10;
$b=20;

/* Arithmetic operations */
/*Addition*/
echo "The Sum of the two numbers is ". ($a+$b) . ".<br>";

/*Subtraction*/
echo "The Difference of two numbers is ". ($a-$b) .".<br>";

/*Multiplication*/
echo "The Product of the two numbers is ". ($a*$b) .".<br>";

/*Division*/
echo "The Quotient of the two numbers is ". ($a/$b) .".<br>";

/*Modulus*/
echo "The Remainder of the two numbers is " . ($a%$b) .".<br>";
?>
Output:
The Sum of the two numbers is 30.
The Difference of two numbers is -10.
The Product of the two numbers is 200.
The Quotient of the two numbers is 0.5.
The Remainder of the two numbers is 10.

PHP arithmetic operators are just as easy to use as other programming languages. If the two operands are not integers, it will return a float value.