Math Operations in PHP

Addition ($a + $b): 5 + 10 = 15

Addition: This operator adds two values together.

Subtraction ($b - $a): 10 - 5 = 5

Subtraction: This operator subtracts one value from another.

Multiplication ($a * $b): 5 * 10 = 50

Multiplication: This operator multiplies two values together.

Division ($b / $a): 10 / 5 = 2

Division: This operator divides one value by another.

Modulus ($b % $a): 10 % 5 = 0

Modulus: This operator returns the remainder of the division of two values.

Source Code

<?php
// Addition
$a = 5;
$b = 10;
$addition = $a + $b;
echo "<p>Addition (\$a + \$b): $a + $b = $addition</p>";
echo "<p>Addition: This operator adds two values together.</p>";

// Subtraction
$subtraction = $b - $a;
echo "<p>Subtraction (\$b - \$a): $b - $a = $subtraction</p>";
echo "<p>Subtraction: This operator subtracts one value from another.</p>";

// Multiplication
$multiplication = $a * $b;
echo "<p>Multiplication (\$a * \$b): $a * $b = $multiplication</p>";
echo "<p>Multiplication: This operator multiplies two values together.</p>";

// Division
$division = $b / $a;
echo "<p>Division (\$b / \$a): $b / $a = $division</p>";
echo "<p>Division: This operator divides one value by another.</p>";

// Modulus
$modulus = $b % $a;
echo "<p>Modulus (\$b % \$a): $b % $a = $modulus</p>";
echo "<p>Modulus: This operator returns the remainder of the division of two values.</p>";
?>