html_entity_decode第一次无法正常工作

时间:2015-07-17 00:54:28

标签: php html

我有一串html要解码并删除html标签,然后再通过电子邮件发送出来。

这是字符串:

<p>This is a test <em>please </em><strong>ignore </strong>it &gt;&lt;&nbsp;, thank you.</p>

使用html_entity_decode和strip_tags解码并剥离html标签后,我仍然会留下一些html实体。

strip_tags(html_entity_decode($str));
//got result as This is a test please ignore it &gt;&lt;&nbsp;, thank you.

只做另一个html_entity_decode会给我正确的结果:

html_entity_decode(strip_tags(html_entity_decode($str)));
  • 该字符串直接取自CKEditor的post变量。

我不明白为什么第一个html_entity_decode没有做到这一点,需要另一个html_entity_decode。有人可以向我解释一下吗?

提前致谢。

0 个答案:

没有答案
相关问题