PHP Operators and Basic Math
Use arithmetic, comparison, and logical operators to build conditions and logic.
Ryan Adams
November 8, 2025
5.1k200
Operators help you perform actions on values.
Arithmetic operators
$a = 10;
$b = 3;
echo $a + $b; // 13
echo $a - $b; // 7
echo $a * $b; // 30
echo $a / $b; // 3.33
echo $a % $b; // 1
Comparison operators
var_dump(5 == "5"); // true
var_dump(5 === "5"); // false (type matters)
Logical operators
if ($age > 18 && $isStudent) {
echo "Adult student";
}
Next: if, else, and decision making.
#PHP#Operators#Beginner