Operators in PHP are a useful way to use mathematics on variables. Whether you want to add, subtract, multiply, divide, or do any other mathematical equation involving a variable or variables, operators are the way to go. The PHP operators are generally the same as mathematical operators which makes them very easy to learn. Below shows examples of how to use basic operators with variables.

In the above code, we made the variable “$number” equal to “1” and the variable “$anothernumber” equal to “1” as well. We then took the variable “$result” and made it equal to “$number” added to “$anothernumber”. Since “$number” and “$anothernumber” are equal to “1”, and 1+1=2, “$result” is now equal to “2”. We used the echo() function to output the result. If you test this script, you’ll see that it outputs “2”.