从数据库PHP解码htmlentities

时间:2013-10-02 19:43:26

标签: php html-entities

我将HTML存储到我的数据库中:

$ohtml = htmlentities($html);

但是当我使用

检索数据时
$new_html = html_entity_decode($ohtml, ENT_QUOTES);

显示的数据没问题,但我希望转换为真正的HTML,而不仅仅是显示代码。防爆。如果$new_html = "<textarea> </textarea>";

,我想显示textarea

1 个答案:

答案 0 :(得分:1)

回复$new_html

$new_html = html_entity_decode($ohtml, ENT_QUOTES);
echo $new_html;

编辑我很慢..尝试理解他的问题花了很长时间其他人已经发布了解决方案的评论......

EDIT2 :试试这段代码吧,它为我工作:

$html = "<b>I hate entities</b>";

$ohtml = htmlentities($html);

$new_html = html_entity_decode($ohtml, ENT_QUOTES);
echo $new_html;
相关问题