多年来,我一直在使用完全相同的代码,但从未遇到过任何问题。现在它突然停止工作了。
我已经在互联网上阅读过有关此问题的信息,显然您需要安装 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
我的 extension=php_intl.dll
php.ini
,它也在我的目录中。
为什么我会收到此错误?
原文由 cannatown 发布,翻译遵循 CC BY-SA 4.0 许可协议
这似乎是一个非常奇怪的问题,我通过执行以下操作以某种方式解决了它:
我通过 本 教程在 Wamp 中升级了我的 PHP。我还在
php.ini
当我升级时它不起作用,所以我恢复到我以前的 PHP 版本,瞧——它起作用了。我完全不知道这是如何解决问题的,但它对我有用。