Php 带标签和nl2br的问题
我试图在我从数据库中回显出来的内容上使用Strip_标签和nl2br。然而,strip_标签不起作用,但nl2br起作用。如果可能的话,我想做的是删除内容中的所有html或php标记。顺便说一下,我正在使用PHP5.2.17。请帮忙 输出Php 带标签和nl2br的问题,php,html,strip-tags,Php,Html,Strip Tags,我试图在我从数据库中回显出来的内容上使用Strip_标签和nl2br。然而,strip_标签不起作用,但nl2br起作用。如果可能的话,我想做的是删除内容中的所有html或php标记。顺便说一下,我正在使用PHP5.2.17。请帮忙 输出 Content: <p><span style="color: #00ff00;">This is a new Page<br /><br />This is a new sentence</span>
Content:
<p><span style="color: #00ff00;">This is a new Page<br /><br />This is a new sentence</span></p>
内容:
这是一个新的页面这是一个新的句子
内容
Content:<br />
<div class="view-content">
<?php echo
strip_tags(htmlentities($current_page["content"])); ?>
</div>
内容:
如果您使用的是strip\u标签
您不需要htmlentites
。您的输出将首先转换为实体,因此您没有任何要剥离的标记。将其更改为:
<?php echo strip_tags($current_page["content"]); ?>
您应该执行以下操作:
echo htmlentities(strip_tags($current_page["content"]));
由于您首先调用htmlentities
,因此无法在内容中识别标记,因为
字符被替换为
和