如何从PHP中的MySQL数据库呈现HTML标记? [英] How to render html tags from mysql database in PHP?
问题描述
我在表格中存储< ul>< li> ....< / li>< / ul>
等html标记。我想检索这些值作为html内容。当我检索这些数据时,我想将它显示为HTML内容,也就是说,它应该显示项目符号而不是< ul>< li> ....< / li>< / ul> ;
I am storing html tags like <ul><li>....</li></ul>
, etc in the table. I want to retrieve these values as html content. When I retrieve this data I want to show it as HTML content, that is, it should show bullets instead of <ul><li>....</li></ul>
.
$ b
代码我正在尝试:
Code which I am trying:
<?php echo stripslashes($row3['description'])?>
我甚至试过 htmlentities()
, html_entity_decode()
但没有任何工作。
I have even tried htmlentities()
, html_entity_decode()
but, none have worked.
推荐答案
htmlspecialchars_decode
函数如下:
You can Use htmlspecialchars_decode
function as below :
echo htmlspecialchars_decode(stripslashes($row3['description']));
而不是
Instead of
echo stripslashes($row3['description']);
您可以在这里了解更多关于函数的信息: http://php.net/manual/en/function.htmlspecialchars-decode.php
You can know more about function here : http://php.net/manual/en/function.htmlspecialchars-decode.php
这篇关于如何从PHP中的MySQL数据库呈现HTML标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!