numfmt_format() expects parameter 1 to be NumberFormatter, null given
-
17-03-2021 - |
Question
I recently upgraded my WAMP server and I can't seem to get the Intl extension to work. I've made sure that
- the extension path in both ini files are correct
- the extension is loaded in both inis
- I can see the extension with
php --re intl
- I can see an example function with
php --rf numfmt_create
- I have icu dlls files in my php folder (icu 46, php 5.3.8, wamp 2.2)
- I have appended
C:\wamp\bin\php\php5.3.8
to the PATH in System variables - The code is correct - working code before wamp upgrade and php manual example codes fail
I'm trying to use the Number Formatter but it gives me some strange errors. Take this example code from the php manual for example:
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL );
echo numfmt_format($fmt, 1234567.891234567890000)."\n";
$fmt = numfmt_create( 'it', NumberFormatter::SPELLOUT );
echo numfmt_format($fmt, 1142)."\n";
?>
It gives me this:
A PHP Error was encountered
Severity: Warning
Message: numfmt_format() expects parameter 1 to be NumberFormatter, null given
Filename: controllers/test.php
Line Number: 867
Backtrace:
File: C:\wamp\www\application\controllers\test.php Line: 867 Function: numfmt_format
File: C:\wamp\www\index.php Line: 260 Function: require_once
A PHP Error was encountered
Severity: Warning
Message: numfmt_format() expects parameter 1 to be NumberFormatter, null given
Filename: controllers/test.php
Line Number: 869
Backtrace:
File: C:\wamp\www\application\controllers\test.php Line: 869 Function: numfmt_format
File: C:\wamp\www\index.php Line: 260 Function: require_once
I notice that numfmt_create()
seems to be returning NULL regardless of what I do.
Solution 2
Apparently the 64 version of WAMP did not have correct icu dlls - using the 32 version worked.
OTHER TIPS
can you run the icuinfo.exe
tool from ICU to see if ICU is loading its data properly?