What are the potential pitfalls of using number_format in PHP for displaying currency values in a webshop?
When using number_format in PHP to display currency values in a webshop, one potential pitfall is that it may not always format the numbers correctly based on the locale settings of the server. To ensure proper formatting, it is recommended to use the NumberFormatter class in PHP, which allows for more control over formatting based on locale settings.
$number = 1234.56;
$fmt = new NumberFormatter('en_US', NumberFormatter::CURRENCY);
echo $fmt->formatCurrency($number, 'USD');