What are the potential pitfalls of using number_format in PHP for rounding numbers?

When using number_format in PHP for rounding numbers, one potential pitfall is that it does not actually round the number, but rather formats it with the specified number of decimal places. To properly round a number, you should use the round function before using number_format.

$number = 10.555;
$roundedNumber = round($number, 2);
$formattedNumber = number_format($roundedNumber, 2);

echo $formattedNumber; // Outputs 10.56