php以html格式显示存储在数据库中的文本

php以html格式显示存储在数据库中的文本,php,html,Php,Html,我有一个文本保存在MySQL数据库中 <p> Celebrate with these amazing<br /> offers direct from the 我得到了这个输出 <p> Celebrate with these amazing<br /> offers direct from the 喜欢HTML打印 当我在db中看到它像吼叫一样存储 &lt;p&gt; Celebrate with thes

我有一个文本保存在MySQL数据库中

<p> Celebrate with these amazing<br /> offers direct from the  
我得到了这个输出

 <p> Celebrate with these amazing<br /> offers direct from the  
喜欢HTML打印

当我在db中看到它像吼叫一样存储

&lt;p&gt;
    Celebrate with these amazing&lt;br /&gt;
    offers from

如何做到这一点?

如果您要输出到控制台,这可能会对您有所帮助(您的问题不清楚您要输出到什么):

如果您查看PHP strip_tags文档,您应该能够获得与您想要的接近的内容

使用strip_tags(),您可以允许保留
标记,然后将其替换为“\n”


否则,如果您正在输出到浏览器,则此页面上的其他帖子会给出答案-您必须将数据的htmlentities()版本存储在数据库中。

假设您的数据库已保存转义信息,如下所示:

&lt;p&gt;
    Celebrate with these amazing&lt;br /&gt;
    offers from

然后,您可以使用PHP函数输出该HTML块。

您确定数据库中存储了Cel….
。。。而不是p Cel…br/??同意@MerianosNikos,看起来您的数据库已经存储了转义的html标记。
&lt;p&gt;
    Celebrate with these amazing&lt;br /&gt;
    offers from
&lt;p&gt;
    Celebrate with these amazing&lt;br /&gt;
    offers from