坚持 strip_tags 为什么不在我的代码中工作?

Stuck with strip_tags why not working in my code?

我想从以下字符串中删除引号和 html 标签:

$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 不起作用?我把这里弄乱了什么?

在该字符串上使用 htmlentities() 后,就没有要删除的标签了,因为它们已经转换为它们的 HTML 实体。

首先使用strip_tags函数如果你想删除html标签然后使用htmlentities 如下所示,它应该是有效的:

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

你能用这个代码吗

echo strip_tags($mystring);