我正在使用NumberFormatter::formatCurrency来显示格式化的货币值,如下所示;
$value = 395;
$fmt = numfmt_create('en_GB', NumberFormatter::CURRENCY);
echo numfmt_format_currency($fmt, $value, 'gbp');
在我的Windows开发盒和Centos UAT盒上,这输出了所需的395英镑。
但在量产的 Centos 盒子上,它输出 395 英镑。
知道缺少什么吗?我已检查已启用 intl 扩展。
我的语言环境文件可能有问题吗?当我打字时
区域设置 -a
在命令行中,我得到了一长串语言环境,en_GB就是其中之一。
也许en_GB
不是系统上的有效区域设置。尝试en_GB.UTF-8
或en_GB.ISO-8559-1
NumberFormatter
类不正确,英镑需要大写,如下所示:'GBP'
试试这个:
$value = 395;
$currencyFormat = new NumberFormatter('en_GB', NumberFormatter::CURRENCY);
echo $currencyFormat->formatCurrency($value, 'GBP');
这将呈现£395.00