ceil()
ceil() — Round fractions up.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
Returns the next highest integer value by rounding up num if necessary.
Signature
ceil(int|float $num): float
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $num | int|float | The value to round |
Return value
num rounded up to the next highest integer. The return value of ceil() is still of type float as the value range of float is usually bigger than that of int.
Example
A runnable snippet:
echo ceil(4.3), PHP_EOL; // 5 echo ceil(9.999), PHP_EOL; // 10 echo ceil(-3.14), PHP_EOL; // -3
Changelog
| Version | Change |
|---|---|
| 8.0.0 | num no longer accepts internal objects which support numeric conversion. |
See also
All PHP 8.5 built-in functions
Reference card built from the PHP manual page ceil() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.