致命错误:找不到类'NumberFormatter'
P粉817354783
P粉817354783 2023-08-16 16:29:06
[PHP讨论组]
<p>我已经使用这段完全相同的代码很久了,从来没有出过任何问题。突然间它停止工作了。</p> <p>我在互联网上阅读了关于这个问题的资料,显然你需要安装<code>PHP 5.3或更高版本</code>,以及安装<code>PHP intl</code>插件。我两者都有,但是每当我使用下面的函数时,我仍然收到一个<code>致命错误:找不到类'NumberFormatter'</code>的错误:</p> <pre class="brush:php;toolbar:false;">function format_item($value) { $format = new NumberFormatter('en_US', NumberFormatter::CURRENCY); return $format-&gt;formatCurrency($value, 'AUD'); }</pre> <p>此外,这是我<code>php.ini</code>文件的一部分,显示我已经安装了<code>PHP intl</code>插件:</p> <pre class="brush:php;toolbar:false;">[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</pre> <p>我还在我的<code>php.ini</code>中添加了<code>extension=php_intl.dll</code>,并且它也在我的目录中。</p> <p>为什么我会收到这个错误?</p>
P粉817354783
P粉817354783

全部回复(2)
P粉409742142

你所需要的是:

apt-get install php7.0-intl

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

这里最受欢迎的答案是让你取消注释一个.dll文件,除非你在Windows服务器上,否则这永远不会解决任何问题!

P粉237029457

这似乎是一个非常奇怪的问题,我通过以下方式解决了它:

我通过这个教程升级了我的Wamp中的PHP。我还更新了php.ini中的时区设置。当我升级后,它没有起作用,所以我恢复回了之前的PHP版本,然后问题就解决了。

我完全不知道这样做为什么能解决问题,但对我来说有效。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号