致命错误:找不到类“数字格式化程序”

php
2022-08-30 08:57:16

多年来,我一直在使用这个完全相同的代码,我从来没有遇到过一个问题。现在突然间,它已经停止工作了。

我已经在互联网上阅读了有关此问题的信息,显然您需要安装并安装插件。我同时拥有这两个功能,但每当我使用以下函数时,我仍然收到错误:PHP 5.3 or higherPHP intlFatal error: Class 'NumberFormatter' not found

function format_item($value)
{
       $format = new \NumberFormatter('en_US', \NumberFormatter::CURRENCY);
       return $format->formatCurrency($value, 'AUD');
}

另外,这是我文件中的截图,显示我已安装插件:php.iniPHP 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.dllphp.ini

为什么我会收到此错误?


答案 1

您只需要通过取消注释以下行来启用此扩展:php.ini

extension=ext/php_intl.dll

有关更多详细信息,请访问启用 intl 扩展


答案 2

您所需要的只是:

apt-get install php7.0-intl

无需更改php.ini或执行任何其他操作。(在 Ubuntu 16.04 上的 PHP 7 上测试)。

这里投票最多的答案是你取消评论一个.dll除非你在Windows服务器上,否则永远不会解决任何事情!


推荐