ceil() function in PHP

PHPProgrammingServer Side Programming

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>
raja
Published on 09-Nov-2018 06:32:34
Advertisements