Introduction
Integers are whole numbers without decimals. They are used to count or measure things exactly.
Integers are whole numbers without decimals. They are used to count or measure things exactly.
<?php $number = 123; $negative = -456; $zero = 0; ?>
Integers can be positive, negative, or zero.
PHP automatically treats numbers without decimals as integers.
<?php $age = 30; $score = -15; $zero = 0; ?>
<?php $bigNumber = 2147483647; // largest 32-bit integer $smallNumber = -2147483648; // smallest 32-bit integer ?>
<?php $sum = 10 + 5; // 15 $diff = 10 - 3; // 7 ?>
This program shows how to use integers to count fruits, show negative numbers, and zero.
<?php $apples = 5; $oranges = 3; $total = $apples + $oranges; echo "Total fruits: $total\n"; $negativeNumber = -10; echo "Negative number: $negativeNumber\n"; $zero = 0; echo "Zero value: $zero\n"; ?>
PHP integers can be 32-bit or 64-bit depending on your system.
If a number is too big for an integer, PHP converts it to a float automatically.
Use var_dump() to check the type of a variable.
Integers are whole numbers without decimals.
They can be positive, negative, or zero.
Use integers when you need exact whole numbers for counting or math.
$a = 5; $b = 2; $c = $a / $b; echo (int)$c;
$num = 0123; echo $num;
Pass the test and this pattern moves unknown