Locked lesson.
About this lesson
Learn how to do math in PHP.
Exercise files
Download this lesson’s related exercise files.
Arithmetic Operators.docx58.8 KB Arithmetic Operators - Solution.docx
59.1 KB
Quick reference
Arithmetic Operators
We can do math with Arithmetic Operators.
When to use
Anytime you want to do any sort of math, you'll use arithmetic operators.
Instructions
Math operators act just the way you'd think they do.
+ add
- subtract
* multiply
/ divide
** or pow() exponent
% modulus (remainder)
You can use math operators on variables or on the numbers directly themselves:
echo $num1 + $num2;
or
echo 3 + 5;
Hints & tips
- Arithmetic operators allow us to do math.
- They work exactly how you'd think they would.
Lesson notes are only available for subscribers.