In PHP, the arithmetic operators works same as other programming languages simply like as $c=$a + $b (c is the sum of the a and b).
In the following example we will perform some arithmetic operations, see the following example:
<? Php $num1 = 5; $num2 = 15; $num3 = 4; $num4 = 4; $TotalSum = $num1 + $num2 + $num3 + $num4; $AvgNum = ($num1 + $num2 + $num3 + $num4)/4; Echo “the sum of the numbers is : $TotalSum “; Echo “the average of the numbers is : $AvgNum”; ?>
Output will be above program is:
the sum of the numbers is 28
the average of the numbers is : 7