• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

PHP ceil function – Round fractions up

by admin

Description

Returns an integer that is the next larger than the float used as the argument. In essence, it rounds up a floating-point number to an integer, no matter what the value of the floating-point integer is. It doesn’t round down.

Syntax:

ceil(int|float $num): float

The ceil() function takes a floating-point number as its only parameter and rounds it to the nearest integer above its current value. If you provide an integer, nothing will happen. For example:

$number = ceil(11.9); // 12
$number = ceil(11.1); // 12
$number = ceil(11); // 11

Parameters

Parameter Description
num The value to round.

Return Values

num rounded up to the next highest integer. The return value of ceil() is still of type float as the value range of float is usually bigger than that of int.

Examples

Example 1: Round up a floating-point number:

$number = 12.023; 
echo "The next highest integer of $number is ", ceil($number);

Example 2:

echo ceil(4.3);    // 5
echo ceil(9.999);  // 10
echo ceil(-3.14);  // -3

Filed Under: PHP

Some more articles you might also be interested in …

  1. PHP Function str_word_count() – Return information about words used in a string
  2. PHP connection_status function – Returns connection status bitfield
  3. htaccess Cheatsheet
  4. PHP asin function – Arc sine
  5. PHP function str_ireplace() – Case-insensitive version of str_replace()
  6. PHP function strcmp() – Binary safe string comparison
  7. PHP function acos – Arc cosine
  8. PHP Function str_split() – Convert a string to an array
  9. How to test a PHP script
  10. PHP function strcasecmp() – Binary safe case-insensitive string comparison

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright