我正在将PHP应用程序移动到另一台服务器,我遇到了一些字符解码问题:
旧服务器(带有Plesk Panel的CentOS):
echo htmlentities('ú'), ENT_QUOTES, 'UTF-8'); // Result ú
echo html_entity_decode('ú', ENT_QUOTES, 'UTF-8'); // Result ú <= expected
新服务器(Debian专用服务器,全新安装):
echo htmlentities('ú'), ENT_QUOTES, 'UTF-8'); // Result ú
echo html_entity_decode('ú', ENT_QUOTES, 'UTF-8'); // Result ú <= not expected
echo html_entity_decode('ú', ENT_QUOTES, 'ISO-8859-1'); // Result ú <= expected
为什么会这样?可能是服务器配置问题?
答案 0 :(得分:1)
尝试以下
echo htmlentities('ú', ENT_QUOTES, 'UTF-8');
echo html_entity_decode('ú', ENT_QUOTES, 'ISO-8859-1');