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.
ceil(int|float $num): float
This function requires a number to round up as a parameter.
ceil()
returns the nearest smallest integer greater than or equal to the number sent as a parameter.
The function’s return type is
float
as the value range offloat
is greater than that of the integer.
<?php #Positive number echo ("ceil(10): "); echo (ceil(10)); echo ("\n"); echo ("ceil(5.3): "); echo (ceil(5.3)); ?> <?php #Negative number echo ("ceil(-10): "); echo (ceil(-10)); echo ("\n"); echo ("ceil(-5.3): "); echo (ceil(-5.3)); ?>
RELATED TAGS
CONTRIBUTOR
View all Courses