我已经使用这个完全相同的代码多年了,我从来没有遇到过一个问题.现在突然间它停止了工作.
我已经通过互联网阅读了这个问题,显然你需要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');
}
Run Code Online (Sandbox Code Playgroud)
另外,这是我的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
Run Code Online (Sandbox Code Playgroud)
我也有extension=php_intl.dll …
我想使用Moodle,但在安装过程中出错:
应安装并启用php_extension-> intl->以获得最佳结果.
Intl扩展用于改进国际化支持,例如区域设置感知排序.
当我点击链接时,我收到上面的错误消息: http://docs.moodle.org/24/en/admin/environment/php_extension/intl
我跟着那个链接,但我仍然得到同样的错误.如果有人有任何想法,请帮助我.
我的系统是Ubuntu 12.04,PHP 5.3,我正在尝试运行一些基本的Intl代码,如下所示:
<?php
$coll = collator_create('en_US');
$result = collator_compare($coll, "string#1", "string#2");
Run Code Online (Sandbox Code Playgroud)
它输出
PHP Fatal error: Call to undefined function collator_create()
Run Code Online (Sandbox Code Playgroud)
自版本5.3以来,不应该将Intl扩展与PHP捆绑在一起吗?
apt-get使用此命令行安装PHP (我不使用Apache):
apt-get install php5 php5-cli php5-mysql php5-cgi php5-fpm php5-curl php-apc php5-memcache php5-memcached php5-common php5-gd php-xml-parser php-pear php5-imap php5-mcrypt php5-xdebug php5-suhosin
Run Code Online (Sandbox Code Playgroud)
以下是php -v产生的结果:
PHP 5.3.10-1ubuntu3.5 with Suhosin-Patch (cli) (built: Jan 18 2013 23:40:19)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick …Run Code Online (Sandbox Code Playgroud)