2016-11-04 106 views
-1

我想从以下字符串中删除引号和HTML标签:卡住strip_tags为什么不能在我的代码中工作?

$mystring='Example string "I want to remove any html tags ABC<sub>DE</sub> from <p>similar</p> types of string?"'; 

我使用下面的脚本来删除它,但它是对我不起作用:

echo strip_tags(htmlentities($mystring,ENT_QUOTES)); 

我想下面的输出对于上面的字符串:

Example string "I want to remove any html tags ABCDE from similar types of string?" 

为什么strip不起作用?我在这里弄到了什么?

回答

0

在第一次使用如果你想删除HTML标签,然后使用ヶ辆如下它应该是工作用strip_tags功能:

echo htmlentities(strip_tags($mystring),ENT_QUOTES); 
+0

我必须从字符串中脱离单引号或双引号以及条形标记。该脚本正常工作。谢谢 – ThoHua

7

一旦您在该字符串上使用htmlentities(),则没有标签可以剥离,因为它们已被转换为HTML实体。

+0

同意.. .... ... – devpro

0

您可以使用此代码

echo strip_tags($mystring); 
相关问题