小编Fra*_*ank的帖子

PHP NumberFormatter 总是给我默认的 en_US

当尝试在我的 PHP 8.1 alpine docker 容器中格式化货币时,我总是得到默认区域设置 (en_US)。

\n
$ docker run -it --rm php:8.1-fpm-alpine /bin/ash\n# apk update && apk add icu-dev\n# docker-php-ext-configure intl && docker-php-ext-install intl\n# php -a\n> $formatter = new NumberFormatter('nl_NL', NumberFormatter::CURRENCY);\n> echo $formatter->getLocale();\nen_US\n> echo $formatter->format(1234.567);\n\xe2\x82\xac1,234.57\n
Run Code Online (Sandbox Code Playgroud)\n

我期望 getLocale() 返回 nl_NL 和 format 返回 \xe2\x82\xac1.234,57。

\n

如果我尝试 locale en_GB,getLocale() 确实返回 en_GB。

\n

也欢迎任何有关编写更好问题的建议。

\n

php intl docker alpine-linux

5
推荐指数
1
解决办法
631
查看次数

标签 统计

alpine-linux ×1

docker ×1

intl ×1

php ×1