What is the best practice for outputting decimal places as actual numbers in PHP?

When outputting decimal places as actual numbers in PHP, it is best practice to use the number_format() function. This function allows you to format a number with grouped thousands and specify the number of decimal places to display. By using number_format(), you can ensure that decimal numbers are displayed correctly and consistently across different outputs.

$number = 1234.56789;
$formatted_number = number_format($number, 2);
echo $formatted_number; // Output: 1,234.57