Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
math
ceiling
integer
communitycreator

What is ceil() in PHP?

harris910

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.

Mathematical representation of 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 float as the value range of float is greater than that of the integer.

Example

<?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

php
math
ceiling
integer
communitycreator
RELATED COURSES

View all Courses

Keep Exploring