PHP CHAPTER 09

PHP Numbers

PHP supports numeric values such as integers and floating-point numbers.

📘

What is it?

PHP supports numeric values such as integers and floating-point numbers.

💡

Why do we use it?

Numbers are required for marks, fees, quantities, prices and calculations.

⚙️

How does it work?

PHP performs arithmetic operations on numeric values using operators.

🧩

Syntax

PHP Syntax
$number = 100;
$price = 99.50;
💻

Example

PHP Example
<?php

$fee = 35000;
$discount = 5000;
$finalFee = $fee - $discount;

echo "Final Fee: " . $finalFee;

?>
🔍

Example Explained

$fee stores the original fee. $discount stores the reduction. $finalFee calculates the remaining amount.
🚀

More Examples

<?php $a = 10; $b = 3; echo $a + $b; echo "<br>"; echo $a * $b; ?>

⚠️ Important Rules

Integers are whole numbers. Floats contain decimal values.

❌ Common Mistakes

Using text values in calculations without converting or validating them.

🌍 Real-World Use

Fees, invoices, product prices, marks and reports use numbers.

📝 Practice Exercise

Calculate total marks, percentage and average of five subjects.

💻 Try It Yourself

Write and run this PHP lesson inside the AIFA Coding Lab.

Open Coding Lab →