PHP ceil()

d1r0l's avatar
Published May 26, 2023
Contribute to Docs

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

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours

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:

Code
Output
Loading...

All contributors

Contribute to Docs

Learn PHP on Codecademy

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours