search

Home  >  Q&A  >  body text

Fatal error: Class 'NumberFormatter' not found

<p>I've been using this exact same code for ages and never had any problems. Suddenly it stopped working. </p> <p>I read about this problem on the internet and apparently you need to install <code>PHP 5.3 or higher</code>, as well as install the <code>PHP intl</code> plugin. I have both, but whenever I use the function below I still get a <code>Fatal Error: Not found error for class 'NumberFormatter'</code>:</p> <pre class="brush:php;toolbar:false;">function format_item($value) { $format = new NumberFormatter('en_US', NumberFormatter::CURRENCY); return $format->formatCurrency($value, 'AUD'); }</pre> <p>Also, here is part of my <code>php.ini</code> file showing that I have the <code>PHP intl</code> plugin installed: </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>I also added <code>extension=php_intl.dll</code> in my <code>php.ini</code> and it is also in my directory. </p> <p>Why am I getting this error? </p>
P粉817354783P粉817354783499 days ago579

reply all(2)I'll reply

  • P粉409742142

    P粉4097421422023-08-17 14:47:15

    What you need is:

    apt-get install php7.0-intl

    No need to change php.ini or do anything else. (Tested on Ubuntu 16.04 with PHP 7).

    The most popular answer here is to have you uncomment a .dll file, which will never solve anything unless you are on a Windows server!

    reply
    0
  • P粉237029457

    P粉2370294572023-08-17 12:07:58

    This seems to be a very strange problem, I solved it by:

    I upgraded my PHP in Wamp through this tutorial. I also updated the time zone settings in php.ini. When I upgraded it didn't work so I reverted back to the previous PHP version and the problem was solved.

    I have absolutely no idea why this solves the problem, but it works for me.

    reply
    0
  • Cancelreply