Home >Backend Development >PHP Problem >What is the method of rounding up in php
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.
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:
<?php echo(ceil(0.60) . "<br>"); echo(ceil(0.40) . "<br>"); echo(ceil(5) . "<br>"); echo(ceil(5.1) . "<br>"); echo(ceil(-5.1) . "<br>"); echo(ceil(-5.9)); ?>
Output:
1 1 5 6 -5 -5
Description:
ceil() function is in PHP A built-in function for rounding a number up to the nearest larger integer. Syntax format:
ceil(number);
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!