Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 带标签和nl2br的问题_Php_Html_Strip Tags - Fatal编程技术网

Php 带标签和nl2br的问题

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>

我试图在我从数据库中回显出来的内容上使用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></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
,因此无法在内容中识别标记,因为
字符被替换为