Latest web development tutorials

PHP ceil () function

PHP Math Reference PHP Math Reference

Examples

Rounded 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));
?>

Running instance »

Definition and Usage

ceil () function is rounded up to the nearest integer.

Tip: To be rounded down to the nearest integer, see floor () function.

Tip: For floating-point rounding, please see round () function.


grammar

ceil( number );

参数 描述
number 必需。规定需向上取整的值。

technical details

return value: Rounded up to the nearest whole number.
Return type: Float
PHP version: 4+


PHP Math Reference PHP Math Reference