Arithmatics
In PHP, you can use the following arithmetic operators:
Addition (+): This operator is used to add two operands. For example, $a + $b will add the value of $a to the value of $b.
Subtraction (-): This operator is used to subtract one operand from another. For example, $a - $b will subtract the value of $b from the value of $a.
Multiplication (*): This operator is used to multiply two operands. For example, $a * $b will multiply the value of $a by the value of $b.
Division (/): This operator is used to divide one operand by another. For example, $a / $b will divide the value of $a by the value of $b.
Modulus (%): This operator is used to find the remainder when one operand is divided by another. For example, $a % $b will give the remainder when the value of $a is divided by the value of $b.
Exponentiation (**): This operator is used to raise one operand to the power of another. For example, $a ** $b will raise the value of $a to the power of $b.
Example:
<?php
$a = 10;
$b = 20;
$c = $a + $b; // 30
$d = $b - $a; // 10
$e = $a * $b; // 200
$f = $b / $a; // 2
$g = $b % $a; // 0
$h = $a ** $b; // 100000000000000000000
echo $c . "\n";
echo $d . "\n";
echo $e . "\n";
echo $f . "\n";
echo $g . "\n";
echo $h . "\n";
?>