floor()

floor() — Round fractions down.

Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

What it does

Returns the next lowest integer value (as float) by rounding down num if necessary.

Signature

floor(int|float $num): float

Parameters

ParameterTypeWhat it takes
$numint|floatThe numeric value to round

Return value

num rounded to the next lowest integer. The return value of floor() is still of type float.

Example

A runnable snippet:

echo floor(4.3), PHP_EOL; // 4 echo floor(9.999), PHP_EOL; // 9 echo floor(-3.14), PHP_EOL; // -4

Changelog

VersionChange
8.0.0num no longer accepts internal objects which support numeric conversion.

See also

ceil(), round()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page floor() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.