Integers and Floats
PHP has int and float. intdiv does integer division, % gives remainder and round, floor and ceil handle decimals. PHP_INT_MAX is the largest int.
Example
echo 7 / 2, " ", intdiv(7, 2), " ", 7 % 2, "\n";
echo round(3.14159, 2), " ", floor(2.9), " ", ceil(2.1), "\n";
var_dump(0.1 + 0.2 == 0.3);Result
3.5 3 1 3.14 2 3 bool(false)
Exercise
Integer division.
(7, 2)Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.