致命错误:找不到类'NumberFormatter' [英] Fatal error: Class 'NumberFormatter' not found
问题描述
多年来,我一直在使用这个完全相同的代码,而且我从来没有遇到过任何问题.现在突然间它停止工作了.
I've been using this exact same code for ages, and I have never had a single problem. Now all of a sudden it has stopped working.
我已经在Internet上阅读了有关此问题的信息,显然您需要安装PHP 5.3 or higher
和PHP intl
插件.我同时拥有这两种功能,但是每当使用以下功能时,我仍然会收到Fatal error: Class 'NumberFormatter' not found
错误:
I have read across the internet about this problem, and apparently you need PHP 5.3 or higher
installed, and the PHP intl
plugin installed. I have both of these, yet I am still receiving a Fatal error: Class 'NumberFormatter' not found
error whenever I use the following function:
function format_item($value)
{
$format = new \NumberFormatter('en_US', \NumberFormatter::CURRENCY);
return $format->formatCurrency($value, 'AUD');
}
此外,这是我的php.ini
文件中的片段,显示我已安装PHP intl
插件:
Also, here is a snippit from my php.ini
file showing that I have the PHP intl
plugin installed:
[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
,它也位于我的目录中.
I also have the extension=php_intl.dll
in my php.ini
, and it is also in my directory.
为什么会出现此错误?
推荐答案
这似乎是一个非常奇怪的问题,我通过执行以下操作以某种方式解决了该问题:
This seems to be some really weird problem, and I somehow fixed it by doing the following:
我通过本教程升级了Wamp中的PHP.我还更新了php.ini
中的时区,但在升级时它不起作用,因此我又恢复到了以前的PHP版本,可以正常工作.
I upgraded my PHP in Wamp through this tutorial. I also updated my timezone in php.ini
When I upgraded it didn't work, so I reverted back to my previous version of PHP, and voilà - it worked.
我绝对不知道这是如何解决问题的,但是它对我有用.
I have absolutely no idea how this solved the problem, however it worked for me.
这篇关于致命错误:找不到类'NumberFormatter'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!