Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
599 views
in Technique[技术] by (71.8m points)

php - Fatal error: Class 'NumberFormatter' not found

I've been using this exact same code for ages, and I have never had a single problem. Now all of a sudden it has stopped working.

I have read across the internet about this problem, and apparently you need PHP 5.3 or higher installed, and the PHP intl plugin installed. I have both of these, yet I am still receiving a Fatal error: Class 'NumberFormatter' not found error whenever I use the following function:

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

Also, here is a snippit from my php.ini file showing that I have the PHP intl plugin installed:

[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

I also have the extension=php_intl.dll in my php.ini, and it is also in my directory.

Why am I getting this error?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You just need to enable this extension in php.ini by uncommenting this line:

extension=ext/php_intl.dll

For more details visit, Enable intl extension


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...