多年来,我一直在使用这个完全相同的代码,而且我从来没有遇到过任何问题。现在,它突然停止工作了。
我在网上读到过关于这个问题的文章,显然你需要安装PHP 5.3 or higher
,安装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
中也有php.ini
,它也在我的目录中。
我为什么要犯这个错误?
发布于 2019-03-10 22:13:03
这对我有用(Ubuntu18.10,PHP 7.2.15)
sudo apt-get install php-intl
service apache2 restart
https://stackoverflow.com/questions/30554177
复制相似问题