What is the method of rounding up in php

青灯夜游
Release: 2023-03-11 11:06:02
Original
9047 people have browsed it

In PHP, you can use the ceil() function to round up, which can round up to the nearest integer; the syntax format is "ceil(number);", and the parameter number is used to specify the number to be rounded up. Rounded value.

What is the method of rounding up in php

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

php is rounded up

In PHP, you can use the ceil() function to round up.

The code example is as follows:

"); echo(ceil(0.40) . "
"); echo(ceil(5) . "
"); echo(ceil(5.1) . "
"); echo(ceil(-5.1) . "
"); echo(ceil(-5.9)); ?>
Copy after login

Output:

1 1 5 6 -5 -5
Copy after login

Description:

ceil() function is in PHP A built-in function for rounding a number up to the nearest larger integer. Syntax format:

ceil(number);
Copy after login

The ceil() function accepts a single parameter number, which represents the number that you want to round to the nearest larger integer.

Return value: The return type of the ceil() function is float, which can return the nearest integer value rounded up.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What is the method of rounding up in php. 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!