我已经使用这个完全相同的代码多年了,我从来没有遇到过一个问题.现在突然间它停止了工作.
我已经通过互联网阅读了这个问题,显然你需要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文件中的snippit,显示我已经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,它也在我的目录中.
为什么我收到此错误?
Nic*_*ick 22
所有你需要的是:
apt-get install php7.0-intl
无需更改php.ini或执行任何其他操作.(在Ubuntu 16.04上的PHP 7上测试过).
这里最高投票的答案让你取消注释.dll除非你在Windows服务器上,否则永远无法解决任何问题!
Won*_*ane 16
这对我有用(Ubuntu 18.10,PHP 7.2.15)
sudo apt-get install php-intl
service apache2 restart
key*_*eya 10
我使用PHP 5.5版本并在Ubuntu机器中得到相同的错误.我已经安装了php5-Intl包并重新启动了我的apache服务器.这解决了这个问题.
对于PHP5
sudo apt-get install php5-intl
对于PHP7
sudo apt-get install php7.0-intl
对于Mac OS X,请对PHP5.6使用以下命令
brew install php56-intl
对于不同的操作系统,请查看此页面:http://php.net/manual/en/intl.installation.php
要检查安装是否成功,请运行命令php -m.这应该在列表中显示intl包.
如果您在Mac OS X中使用XAMPP,php-intl有时会产生不同的问题.您可以按照此处提到的调试步骤操作
如果您面临无法加载动态库'/usr/lib/php/extensions/no-debug-non-zts-20121212/intl.so'错误,请按照此处提到的步骤操作
另外,如果有人来到这里并在 Laravel 上使用php artisan serve并面临这个问题,并且已经取消注释
extension=intl
在 php.ini 上,不要忘记重新启动 Laravel 开发服务器。
小智 7
我在 ubuntu-16.04 上运行,我使用的是 php7,我遇到了同样的问题,这是因为php_intl扩展
我修复它的方式-
首先检查您的服务器上是否安装了扩展,使用以下命令进行检查
php -m | grep intl
If there's no results, you must need to install it
If not installed, let's install it
sudo apt-get update
sudo apt-get install php-intl
Finally you need to restart your web server after you install
Class 'NumberFormatter' not found error in simple PHP program
https://www.howtoinstall.co/en/ubuntu/xenial/php-intl
这意味着您intl的 PHP 软件包未安装和/或未启用。
第1步
确保安装php7.2-intl(或检查是否已安装)。就我而言,我使用的是 PHP 7.2,但版本可能会发生变化。
要安装,我使用
sudo apt install php7.2-intl
第2步
安装成功后php.ini,通过去掉注释去启用那个扩展,如下
extension=intl
第 3 步
重启apache
sudo service apache2 restart
如果您使用的是 Google App Engine,只需添加:
extension = "intl.so"
到您的应用程序的 php.ini 文件。
https://cloud.google.com/appengine/docs/php/runtime
| 归档时间: | 
 | 
| 查看次数: | 42701 次 | 
| 最近记录: |