PHP Math
Operators
<?php
# Set some variables.
$x = 5;
$y = 8;
# Addition: use the 'plus' symbol.
echo $x + $y;
echo '<br>';
# Subtraction: use the 'minus' symbol.
echo $y - $x;
echo '<br>';
# Multiplication: use the 'asterisk' symbol.
echo $x * $y;
echo '<br>';
# Division: use the 'forward slash' symbol.
echo $x / $y;
echo '<br>';
# Modulus: use the 'percent' symbol.
echo $y % $x;
echo '<br>';
# Power: use two 'asterisk' symbols to calculate one number to the power of another.
echo $x ** $y;
?>
# Set some variables.
$x = 5;
$y = 8;
# Addition: use the 'plus' symbol.
echo $x + $y;
echo '<br>';
# Subtraction: use the 'minus' symbol.
echo $y - $x;
echo '<br>';
# Multiplication: use the 'asterisk' symbol.
echo $x * $y;
echo '<br>';
# Division: use the 'forward slash' symbol.
echo $x / $y;
echo '<br>';
# Modulus: use the 'percent' symbol.
echo $y % $x;
echo '<br>';
# Power: use two 'asterisk' symbols to calculate one number to the power of another.
echo $x ** $y;
?>
Browser Output
13
3
40
0.625
3
390625
3
40
0.625
3
390625