Why doesn't strip_tags work in PHP?

不想你离开。 提交于 2019-12-02 22:47:15

try:

<?php echo strip_tags(html_entity_decode($firstArticle->introtext)); ?>

very curious that strip-tags does not work....

maybe your "<p>" is htmlentity-encoded? like "&lt;p&gt;" (have a look at the page's sourcecode)

otehrwise this will replace all tags, also htmlentity-encoded ones, but it's nearly obvious that this p-tag is simply htmlentity-encoded so try that first...

preg_replace('/(?:<|&lt;).*?(?:>|&gt;)/', '', $firstArticle->introtext);

In my case, I should use htmlspecialchars_decode($str);. html_entity_decode($firstArticle->introtext) doesn't seem to work for me.

Sometimes I have to use htmlentities first.

        $txt = htmlentities($txt, null, 'utf-8');   
        $txt = htmlspecialchars_decode($txt);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!