What potential pitfalls should be considered when using number_format for multiple calculations in PHP?

When using number_format for multiple calculations in PHP, it's important to remember that number_format returns a formatted string, not a numeric value. This means that if you perform calculations on the formatted numbers, you may encounter unexpected results due to the string formatting. To avoid this issue, it's recommended to only use number_format for displaying the final result, and perform all calculations on the raw numeric values.

$number1 = 1000;
$number2 = 500;
$sum = $number1 + $number2;

// Perform calculations on raw numeric values
$formatted_sum = number_format($sum, 2);

echo $formatted_sum; // Display the formatted result