gpt4 book ai didi

php - html_entity_decode 未按预期工作

转载 作者:太空宇宙 更新时间:2023-11-04 05:03:14 26 4
gpt4 key购买 nike

我正在将 PHP 应用程序移动到另一台服务器,但在字符解码方面遇到一些问题:

旧服务器(带有 Plesk Panel 的 CentOS):

echo htmlentities('ú'), ENT_QUOTES, 'UTF-8'); // Result ú
echo html_entity_decode('&uacute', ENT_QUOTES, 'UTF-8'); // Result ú <= expected

新服务器(Debian 专用服务器,全新安装):

echo htmlentities('ú'), ENT_QUOTES, 'UTF-8'); // Result &uacute;    
echo html_entity_decode('&uacute', ENT_QUOTES, 'UTF-8'); // Result ú <= not expected
echo html_entity_decode('&uacute', ENT_QUOTES, 'ISO-8859-1'); // Result ú <= expected

为什么会发生这种情况?也许是服务器配置问题?

最佳答案

尝试以下

echo htmlentities('ú', ENT_QUOTES, 'UTF-8');
echo html_entity_decode('&uacute;', ENT_QUOTES, 'ISO-8859-1');

关于php - html_entity_decode 未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26256085/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com