Example 1 — Basic ceil() usage
This example rounds up positive and negative decimals and also shows that a whole number stays the same.
<?php
echo ceil(4.1) . PHP_EOL;
echo ceil(4.9) . PHP_EOL;
echo ceil(-4.1) . PHP_EOL;
echo ceil(5) . PHP_EOL; How It Works
- ceil(4.1) moves up to the next whole number, 5.
- ceil(4.9) also becomes 5.
- ceil(-4.1) rounds up toward zero, so the result is -4.
- ceil(5) is already whole, so it stays 5.

