Saturday, July 25, 2026
HomeLanguagesPHP floor() Function

PHP floor() Function

We sometimes need to round down the float values to the next lowest integer in our maths problems. 

PHP provides a built-in function floor() to get this task done through our PHP script. The floor() function in PHP rounds down the float value to the next lowest integer value.

Syntax:

float floor(value)

Parameters: This function accepts the single parameter value which is rounded down to the next lowest integer. 

Return Value: The return type is a float value. It returns the next lowest integer value as a float which is rounded down, only if necessary.

Examples:

Input : floor(1.9)
Output : 1

Input : floor(-1.8)
Output : -2

Input : floor(4)
Output : 4

Note: floor() function is opposite to ceil() function in PHP

Below programs illustrate the floor() function in PHP.

  • When a positive decimal number is passed.

PHP




<?php
    echo floor(2.8);
?>


Output:

2
  • When a negative decimal number is passed.

PHP




<?php
    echo floor(-3.4);
?>


Output:

-4
  • When a number without decimal places is passed.

PHP




<?php
    echo floor(2);
?>


Output:

2

Reference: https://www.php.net/manual/en/function.floor

RELATED ARTICLES

2 COMMENTS

Most Popular

Dominic
32520 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6903 POSTS0 COMMENTS
Nicole Veronica
12017 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12115 POSTS0 COMMENTS
Shaida Kate Naidoo
7023 POSTS0 COMMENTS
Ted Musemwa
7265 POSTS0 COMMENTS
Thapelo Manthata
6980 POSTS0 COMMENTS
Umr Jansen
6972 POSTS0 COMMENTS