What is ceil() in PHP?
The ceil() function returns the smallest integer that is greater than or equal to the number whose ceiling needs to be calculated.
The following illustration shows the mathematical representation of the ceil() function and the corresponding expression in PHP.
Syntax
ceil(int|float $num): float
Parameter
This function requires a number to round up as a parameter.
Return value
ceil() returns the nearest smallest integer greater than or equal to the number sent as a parameter.
The function’s return type is
floatas the value range offloatis greater than that of the integer.
Example
<?php#Positive numberecho ("ceil(10): ");echo (ceil(10));echo ("\n");echo ("ceil(5.3): ");echo (ceil(5.3));?><?php#Negative numberecho ("ceil(-10): ");echo (ceil(-10));echo ("\n");echo ("ceil(-5.3): ");echo (ceil(-5.3));?>