This program will help you to understand how to perform arithmetic operations in PHP
programming.
For a better understanding of this example, we always recommend you to learn the basic topics of PHP programming listed below:
Arithmetic operations include
STEP 1: Declare two variables and assign values to them.
STEP 2: Perform the addition of two variables and display the result.
STEP 3: Perform the subtraction of two variables and display the result.
STEP 4: Perform the multiplication of two variables and display the result.
STEP 5: Perform the division of two variables and display the result.
STEP 6: Perform the modulo of two variables and display the result.
STEP 7: Perform the exponentiation of two variables and display the result.
<?php
$x=20;
$y=10;
$z=$x+$y;
echo "Sum $x+$y = ",$z, "<br>";
$z=$x-$y;
echo "Difference $x-$y = ",$z, "<br>";
$z=$x*$y;
echo "Product $x*$y = ",$z, "<br>";
$z=$x/$y;
echo "Division $x/$y = ",$z, "<br>";
$y=15;
$z=$x%$y;
echo "Modulo $x%$y = ",$z, "<br>";
$y=2;
$z=$x**$y;
echo "Modulo $x**$y = ",$z, "\n";
?>
Sum 20+10 = 30 Difference 20-10 = 10 Product 20*10 = 200 Division 20/10 = 2 Modulo 20 = 5 Modulo 20**2 = 400