Example 1 — Normal division
When the divisor is not zero, fdiv() works like the / operator.
<?php
echo fdiv(10, 4) . PHP_EOL;
echo fdiv(9, 3) . PHP_EOL;
echo round(fdiv(1, 3), 4) . PHP_EOL; How It Works
- fdiv(10, 4) divides 10 by 4 and returns the float 2.5.
- fdiv(9, 3) gives exactly 3, and PHP prints the float 3.0 as 3.
- fdiv(1, 3) gives a long decimal, so round() limits it to four places.
- The return type is always float, even when the answer looks like a whole number.

