php怎样直接输出HTML代码而不被编译?

我是个新手,我想输出 <div>sssss</div>;这段语句,
如果我写 echo '<div>sssss</div>';输出的结果还是 sssss;怎样才能直接显示<div>sssss</div>;

通过PHP的一个内置的函数htmlspecialchars($html);

如果你要是先把一段HTML代码存入数据库在取出来的话
可以这样入库是 htmlspecialchars($html , ENT_QUOTES);
出库是 htmlspecialchars_decode($html , ENT_QUOTES);
温馨提示:内容为网友见解,仅供参考
第1个回答  2010-08-23
最简单是内容与程序的分离 使用模板
实在是要在PHP里加HTML那么就<div><?php echo 'sssss' ?></div>
或者echo html_entity_decode(htmlentities("<div>sssss</div>"));
第2个回答  2010-08-24
echo htmlspecialchars_decode(<div>sssss</div>);

参考资料:phptogether.com

第3个回答  2010-08-23
echo html_entity_decode(htmlentities("<div>sssss</div>"));

参考资料:http://php.net/manual/en/function.html-entity-decode.php

本回答被提问者采纳
第4个回答  2010-08-23
echo '<div>sssss</div>'
相似回答