What is the method for rounding up in PHP?

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

$number = 7.2;

$result = ceil($number);

echo $result; // 输出 8

$number = -4.6;

$result = ceil($number);

echo $result; // 输出 -4

The `ceil()` function will return the smallest integer greater than or equal to the given number. If the number is already an integer, it will return the original value. If the number is negative, it will return the next integer (the one closer to positive infinity).

bannerAds