为什么html_entity_decode()错误地解码“ó”


Why html_entity_decode() decodes "ó" incorrectly?

为什么html_entity_decode()将"ó"解码为未知字符?

echo "ó -> ".html_entity_decode('ó');

给出以下结果:

ó -> �

原始格式(不由浏览器解释):

ó -> �

字符集是 UTF8。

这是因为默认编码是ISO-8859-1的(对于5.4之前的PHP)。将其设置为 UTF-8html_entity_decode 的第三个参数中。