ceil() function in PHP


The ceil() function rounds a number to the nearest integer. The value is rounded up to the nearest greatest integer.

Syntax

ceil(num)

Parameters

  • num − The number to round up

Return

The ceil() function Returns the value rounded up to the nearest (up) integer.

Example

 Live Demo

<?php
   echo(ceil(0.90) . "<br>");
   echo(ceil(0.15) . "<br>");
?>

Output

1<br>1<br>

Example

Let us see another example −

 Live Demo

<?php
   echo(ceil(2));
?>

Output

2

Example

Let us see another example −

 Live Demo

<?php
   echo(ceil(8.9) . "<br>");
   echo(ceil(-9.2) . "<br>")
?>

Output

9<br>-9<br>

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 26-Dec-2019

173 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements