PHP ceil() Function
Example
Round numbers up to the nearest integer:
<?php
echo(ceil(0.60) . "<br>");
echo(ceil(0.40) . "<br>");
echo(ceil(5) . "<br>");
echo(ceil(5.1) . "<br>");
echo(ceil(-5.1) . "<br>");
echo(ceil(-5.9));
?>
Try it Yourself »
Definition and Usage
The ceil() function rounds a number UP to the nearest integer, if necessary.
Tip: To round a number DOWN to the nearest integer, look at the floor() function.
Tip: To round a floating-point number, look at the round() function.
Syntax
ceil(number);
Parameter Values
Parameter | Description |
---|---|
number | Required. Specifies the value to round up |
Technical Details
Return Value: | The value rounded up to the nearest integer |
---|---|
Return Type: | Float |
PHP Version: | 4+ |
❮ PHP Math Reference