Introduction
The PHP math functions are used to handle values within the range of integer and float types. In this article I am describing some of PHP math functions and I am also describes some PHP math functions in PART1.
PHP Ceil() function
The PHP math ceil function rounds (in other words returns the value of a number) the value "upwards" to the nearest integer.
Syntax
| ceil (number) |
Parameters in Ceil function
It contains one parameter.
| Parameter | Description |
| number | It specifies a number to round. |
Example of Ceil function
<html>
<body>
<?php
$ceil1=ceil(4.3);
$ceil2=ceil(-4.3);
$ceil3=ceil(4.335);
$ceil4=ceil(9.4);
$ceil5=ceil(9.9);
$ceil6=ceil(4000.31);
echo "Result of ceil<b> (4.3)</b> is : ". $ceil1. "</br>";
echo "Result of ceil <b>(-4.3) is</b> : ". $ceil2."</br>";
echo "Result of ceil <b>(4.355) is</b> : ". $ceil3."</br>";
echo "Result of ceil <b>(9.4) is</b> : ". $ceil4."</br>";
echo "Result of ceil <b>(9.9) is</b> : ". $ceil5."</br>";
echo "Result of ceil <b>(4005.31)</b> is : ". $ceil6."</br>";
?>
</body>
</html>
Note: In the example above the ceil function takes as its argument a numeric expression. For example ceil(4.3) returns 5, because 5 is the smallest integer that is larger than or equal to the CEIL argument of 4.3.
Output
PHP Floor() function
The PHP math floor function rounds off (in other words returns a value of a number) the value "downwards" to the nearest integer.
Syntax
| floor (number) |
Parameters in Floor function
It contains one parameter.
| Parameter | Description |
| number | It specifies a number to round. |
Example of Floor function
<?php
$floor1=floor(4.3);
$floor2=floor(-4.3);
$floor3=floor(4.335);
$floor4=floor(9.4);



Join the conversation! Your thoughts help the community grow.