我该如何在
.html
页面中显示HTML标签,而不让浏览器执行标签内的内容?你必须使用转义版本。例如,<
变成 <
(没有引号),而 &
变成 &
。
你应该能够找到完整的转换列表。
一个示例代码片段:
<a href="http://google.com">Google</a>
是以下内容的转义版本:
<a href="http://google.com">Google</a>
编辑:
标准实体列表:http://www.w3.org/TR/html4/sgml/entities.html
维基百科文章:http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
highlight_string();
",像这样:<?php
highlight_string('<?php phpinfo(); ?>');
?>
它将以带有彩色编码的字符串形式输出输入。
请查看其PHP文档:
http://php.net/manual/en/function.highlight-string.php
在正文部分插入标签的答案可以通过使用<textarea>
标签来实现。在开放和关闭的<textarea>
标签之间输入的文本或标签将会原样显示。
é
不会被呈现为“é”,而是被解释为“é”。 - Jukka K. Korpela
<
,>
,&
,'
,"
。 - Andrew Marshall