我用这段代码已经很久了,从来没有出过问题,但突然之间就停止工作了。
我在互联网上阅读了有关此问题的资料,似乎需要安装PHP 5.3或更高版本
以及安装PHP intl
插件。 我已经都安装好了,但是每当我使用以下函数时仍然收到Fatal error: Class 'NumberFormatter' not found
错误:
function format_item($value)
{
$format = new \NumberFormatter('en_US', \NumberFormatter::CURRENCY);
return $format->formatCurrency($value, 'AUD');
}
此外,这是我php.ini
文件中的一段代码,显示我已经安装了PHP intl
插件:
[intl]
intl.default_locale = fr_FR
; This directive allows you to produce PHP errors when some error
; happens within intl functions. The value is the level of the error produced.
; Default is 0, which does not produce any errors.
intl.error_level = E_WARNING
我在我的php.ini中也有
extension=php_intl.dll
,而且它也在我的目录中。为什么会出现这个错误?
phpinfo.php
文件,内容为<?php phpinfo(); ?>
,然后浏览该页面。确认您的 PHP 版本和扩展确实已加载。 - Wade'AUD'
。请查看文档:http://php.net/manual/en/numberformatter.formatcurrency.php - Wade