多年来,我一直在使用这个完全相同的代码,而且我从来没有遇到过任何问题。现在,它突然停止工作了。
我在网上读到过关于这个问题的文章,显然你需要安装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
,它也在我的目录中。
我为什么要犯这个错误?
发布于 2015-06-01 01:03:47
这似乎是一个非常奇怪的问题,我做了以下几件事情来解决这个问题:
我通过这教程在Wamp中升级了PHP。我还更新了php.ini
中的时区,当我升级它不起作用时,所以我又回到了以前的PHP版本,而voil又开始工作了。
我完全不知道这是如何解决问题的,但它对我是有效的。
发布于 2015-10-08 10:00:11
发布于 2017-03-20 00:05:57
你所需要的就是:
apt-get install php7.0-intl
不需要更改php.ini或做任何其他事情。(在Ubuntu16.04上的PHP 7上进行测试)。
这里投票最多的答案是取消对.dll的评论,除非您在Windows上,否则它永远解决不了任何问题!
https://stackoverflow.com/questions/30554177
复制相似问题