ceil()

Published May 26, 2023
Contribute to Docs

The ceil() function returns the next highest integer value of the fractional argument.

Syntax

$result = ceil(n);

Where n is the fractional number to find the next highest integer value of.

Example

This example demonstrates the usage of the ceil() function with three different arguments, and outputs results of each on a new line:

<?php
echo ceil(9.4)."</br>";
echo ceil(6.01)."</br>";
echo ceil(-1.637);
?>

It results in the following output:

10
7
-1

Codebyte Example

Using ceil() to return the next highest integer value of 2.718:

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

All contributors

Looking to contribute?

Learn PHP on Codecademy