我尝试在我的 raspberry-pi 上使用 nginX 在 PHP (php-fpm) 中将区域设置从 fr_FR 设置为 us_US.
这是我的代码:
I try to set the locale from fr_FR to us_US in PHP (php-fpm) with nginX on my raspberry-pi.
Here is my code:
<?php
system('locale -a');
/*
C POSIX en_US.utf8 fr_FR fr_FR.iso88591 fr_FR.iso885915@euro fr_FR.utf8
So the en_US locale is well installed
*/
echo locale_get_default();
/* fr_FR */
echo setlocale(LC_ALL, '0');
/*
LC_CTYPE=fr_FR.UTF-8;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;
LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;
LC_MEASUREMENT=C;LC_IDENTIFICATION=C
*/
var_dump(setlocale(LC_ALL, 'en_US.UTF-8', 'en_US.UTF8'));
/* bool(false) */
var_dump(setlocale(LC_ALL, 'fr_FR.UTF8'));
/* string(10) "fr_FR.UTF8"
useless, but it shows that setlocale works with the already set locale */
?>
我不明白为什么 setlocale
返回 false
.
似乎有些东西不起作用,但我无法找到什么.
I don't understand why setlocale
returns false
.
It seems something doesn't work but I don't manage to find what.
在使用 php5-fpm 运行 nginx 的 debian 机器上安装其他语言环境后,我遇到了同样的问题
I had the same problem after installing additional locales on debian machine running nginx with php5-fpm
为了解决这个问题,我不得不重新启动 php5-fpm.
To fix the problem I had to restart php5-fpm.
这篇关于PHP setlocale 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!