Lesson 13 of 3043%
(Progress persistence is disabled until Phase 9)
PHP
Beginner
Arithmetic Operators
Learn about Arithmetic Operators in PHP.
PHP is a powerful server-side language. In this lesson, we will cover Arithmetic Operators.
Real code examples
<?php
$x = 10;
$y = 6;
echo $x + $y . "\n"; // Addition: 16
echo $x - $y . "\n"; // Subtraction: 4
echo $x * $y . "\n"; // Multiplication: 60
echo $x / $y . "\n"; // Division: 1.666...
echo $x % $y . "\n"; // Modulus: 4
echo $x ** $y . "\n"; // Exponentiation: 1000000
?>
Common mistakes
Make sure you include the <?php tag when writing PHP!
Try It Yourself
You can experiment with this in the Playground.