Home > Backend Development > PHP Tutorial > How to use php ceil function?

How to use php ceil function?

藏色散人
Release: 2023-04-06 18:36:01
Original
5525 people have browsed it

php The ceil() function is used to round up to the nearest integer. The syntax is "ceil(num)", which means that the next integer that is not less than the parameter num is returned; if there is no decimal, the parameter num is returned. If there is a decimal part, the decimal part is discarded and moved forward by one place. For example, "ceil(99.4)" returns 100.

How to use php ceil function?

php ceil() function

Function: The function of ceil() function is to round up to the nearest Integer

Syntax:

ceil(number)
Copy after login

Parameters:

number, must be a number,

Description: Returns the next integer that is not less than the parameter number , if there is no decimal, return the parameter number. If there is a decimal part, discard the decimal part and advance one place. Note that it is not rounded. When the parameter is a string string, 0 is returned.

php ceil ()Function example

<?php
$h = 101;
$h = ceil($h);
$i = 99.4;
$i = ceil($i);
$j = -99.4;
$j = ceil($j);
$k = "hello world";
$k = ceil($k);
echo $h."*****".$i."*****".$j."*****".$k;
?>
Copy after login

Output:

101*****100*****-99*****0
Copy after login

The above is the detailed content of How to use php ceil function?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template