PHP ceil()Function
Examples
Rounds 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));
?>
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));
?>
Run Example »
Definition and Usage
The ceil() function rounds a number up to the nearest integer.
Tip:To round a number down to the nearest integer, seefloor()function.
Tip:To round a floating-point number, seeround()function.
Syntax
ceil(number);
| Parameter | Description |
|---|---|
| number | Required. Specifies the value to round up. |
Technical Details
| Return Value: | The nearest integer value rounded up. |
|---|---|
| Return Type: | Float |
| PHP Version: | 4+ |
PHP Math Reference Manual Other Extensions