PHP html_entity_decode Doesn't Decode Entity as Expected?

跟風遠走 提交于 2019-12-13 07:47:59

问题


In the following code:

$string1 = "function doesn't work as expected";
$string2 = html_entity_decode($string1);

$string2 still contains:

 '

...after the call to html_entity_decode().

I've checked other SO threads on this topic, but haven't yet found the answer. What am I missing?


回答1:


The default flags for html_entity_decode do not include single quotes. Try updating your flags argument to include ENT_QUOTES and 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


来源:https://stackoverflow.com/questions/42286695/php-html-entity-decode-doesnt-decode-entity-as-expected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!