Difference Between Ceil and Floor Function in PHP


In this article I will explain Ceil() and Floor() functions in PHP. The ceil() and floor() functions are math functions. First of all I will discuss the ceil() function used to get the next highest integer value by rounding fractions up. The ceil() function is basically used for pagination.


float Ceil($num_value);


Name Description
num_value The value to round

This function returns the value rounded up to the next highest integer value. It returns a rounded value of float.








echo "The Ceil value of 9.4 is  ". $a . "<br />"

echo "The Ceil value of 29.449 is  ". $b . "<br />"

echo "The Ceil value of -8.4 is  ". $c . "<br />"

echo "The Ceil value of 801.9 is  ". $d . "<br />"

echo "The Ceil value of 1200.94 is  ". $e . "<br />"


Ceil function in php.jpg

Next, I will discuss the floor() function. The floor function converts a specified numeric value to the next lowest integer value by rounding.


float Floor($num_value);


Name Description
num_value Pass any numeric value.











echo "The floor value of 20 is $a<br />"

echo "The floor value of -222.14 is $b<br />"

echo "The floor value of 200.25 is $c<br />"

echo "The floor value of -500 is $d<br />"


Floor function in php.jpg

Up Next
    Ebook Download
    View all
    View all