我运行这个PHP代码:
echo "<br>system locales: ".system('locale -a')."<br><br>";
echo "current locales: ".setlocale(LC_ALL, 0)."<br><br>";
var_dump(setlocale (LC_ALL, 'de_DE.utf8'));
echo "current locales: ".setlocale(LC_ALL, 0)."<br><br>";
echo "accepting german characters?: ".ctype_alpha("äüöß")."<br><br>";
echo "accepting characters in general?: ".ctype_alpha("test")."<br><br>";
echo "rejecting numbers?: ".ctype_alpha("tes2t")."<br><br>";
并得到如下的输出:
C C.UTF-8 POSIX de_DE.utf8
system locales: de_DE.utf8
current locales: C
string(10) "de_DE.utf8" current locales: de_DE.utf8
accepting german characters?:
accepting characters in general?: 1
rejecting numbers?
我预计,以后调用setlocale(LC_ALL,“de_DE.utf8”)而ctype_alpha会接受德国的字符,如äöüß,书面文档中: “返回true如果在文本每个字符是从当前的区域设置了一封信,否则返回FALSE。 “ 但事实并非如此。 我到底做错了什么?
PHP版本是:5.3.10-1ubuntu3.8