Thuta Learning
BasicProgrammingbeginner

Operators

Relax. We'll talk through this in plain words — no textbook voice.

Operators are the symbols you use to calculate, compare, and check logic on values. In any real PHP app, calculating prices, checking login conditions, and validating whether form fields are filled in all depend on operators — there's no getting around them.

php
<?php
$stock = 12;
$orderQty = 3;
$isLoggedIn = true;

echo "Remaining stock: " . ($stock - $orderQty) . "<br>";

if ($isLoggedIn && $orderQty <= $stock) {
  echo "Order can be placed.";
}
?>
You should see
Remaining stock: 9 Order can be placed.

Easy traps

  • Using = instead of == (or ===) inside a condition turns a comparison into an assignment by mistake.
Operators | Thuta Learning