Thuta Learning
BasicProgrammingbeginner

Numbers

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

For number data, PHP mainly uses Integer (whole numbers) and Float (decimal numbers). You'll treat things like price, quantity, discount, score, and age as numbers.

php
<?php
$price = 15000;
$discount = 0.10;
$finalPrice = $price - ($price * $discount);

echo "Final price: " . $finalPrice . " MMK";
echo "<br>";
var_dump(is_numeric($finalPrice));
?>
You should see
Final price: 13500 MMK bool(true)

Easy traps

  • Doing calculations on user input without checking whether it's actually a number can lead to warnings, errors, or just plain wrong results.
Numbers | Thuta Learning