本文介绍了PHP html_entity_decode不能按预期解码实体吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在以下代码中:
$string1 = "function doesn't work as expected";
$string2 = html_entity_decode($string1);
$ string2仍然包含:
$string2 still contains:
'
...调用html_entity_decode()之后.
...after the call to html_entity_decode().
我已经检查了有关此主题的其他SO线程,但尚未找到答案.我想念什么?
I've checked other SO threads on this topic, but haven't yet found the answer. What am I missing?
推荐答案
html_entity_decode
的默认标志不包含单引号.尝试更新您的flags参数以包含ENT_QUOTES
和ENT_HTML5
:
$string1 = "function doesn't work as expected";
echo $string2 = html_entity_decode($string1, ENT_QUOTES|ENT_HTML5);
// function doesn't work as expected
这篇关于PHP html_entity_decode不能按预期解码实体吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!