PHP floor () function
Examples
Rounded down to the nearest integer:
<?php
echo(floor(0.60) . "<br>");
echo(floor(0.40) . "<br>");
echo(floor(5) . "<br>");
echo(floor(5.1) . "<br>");
echo(floor(-5.1) . "<br>");
echo(floor(-5.9));
?>
echo(floor(0.60) . "<br>");
echo(floor(0.40) . "<br>");
echo(floor(5) . "<br>");
echo(floor(5.1) . "<br>");
echo(floor(-5.1) . "<br>");
echo(floor(-5.9));
?>
Running instance »
Definition and Usage
floor () function is rounded down to the nearest integer.
Tip: To rounded up to the nearest integer, see ceil () function.
Tip: For floating-point rounding, please see round () function.
grammar
floor( number );
参数 | 描述 |
---|---|
number | 必需。规定需向下取整的值。 |
technical details
return value: | Rounded down to the nearest whole number. |
---|---|
Return type: | Float |
PHP version: | 4+ |
PHP Math Reference