Chapter 5. Working with Numbers
In this lesson you will learn about some of the numeric manipulations you can perform in PHP.
As you would expect, PHP includes all the basic arithmetic operators. If you have not used another programming language, the symbols used might not all be obvious, so we'll quickly run through the basic rules of arithmetic in PHP.
Addition is performed with the plus symbol (
+). This example adds 6 and 12 together and displays the result:
echo 6 + 12;
Subtraction is performed with the minus symbol (
-), which is also used as a hyphen. This example subtracts 5 from 24:
echo 24 - 5;
The minus symbol can also be used to negate a number (for example,
Multiplication is performed with the asterisk ...