PHP floor()Functions

PHP Math 参考手册PHP Math Reference Manual

Examples

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

Run Example »

Definition and Usage

The floor() function rounds a number down to the nearest integer.

Tip:To round up to the nearest integer, see theceil()function.

Tip:To round a floating-point number, see theround()function.


Syntax

floor(number);

Parameters Description
number Required. Specifies the value to round down.

Technical Details

Return value: The nearest integer value rounded down.
Return type: Float
PHP version: 4+


PHP Math 参考手册PHP Math Reference Manual Other Extensions