Skip to content
PHP Logo

What are the differences between the "round()", "ceil()", and "floor()" functions in PHP?

The "round()", "ceil()", and "floor()" functions in PHP are used to round numbers to different precision levels. "round()" rounds a number to the nearest integer, "ceil()" always rounds up to the nearest integer, and "floor()" always rounds down to the nearest integer.

php
$num = 10.4;

echo round($num); // Output: 10
echo ceil($num); // Output: 11
echo floor($num); // Output: 10