【发布时间】:2015-04-10 10:43:50
【问题描述】:
我正在使用以下方法在 html 页面中显示html 代码
<?php $userSuppliedHTML = "<div>snaoj</div>"; ?>
<code><?php echo htmlentities($userSuppliedHTML, ENT_QUOTES, 'UTF-8'); ?></code>
因为我的页面是html,所以我不能运行上面的方法,因为它的php
所以我决定仅基于html使用以下方法
<blockquote>
<pre>
<code>
<div>snaoj</div>
My pre-formatted "quoted" code here.
</code>
</pre>
</blockquote>
pre{
font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
margin-bottom: 10px;
overflow: auto;
width: auto;
padding: 5px;
background-color: #eee;
width: 650px;
padding-bottom: 20px;
max-height: 600px;
}
问题是这个方法不行
谁能帮我在网页上显示代码
【问题讨论】:
-
如果您将其转换为 .php。有什么问题?
-
@anantkumarsingh 但我如何在
php文件代码中显示 php 代码将被执行 -
对不起,我不明白你的问题?你想在一个html文档中执行php代码吗?
-
@martin 我不想想执行php