我在我的网站上有一个允许使用HTML的输入表单,我正在尝试添加关于使用HTML标签的说明。我想让这文本
<strong>Look just like this line - so then know how to type it</strong>
但目前为止我只知道
看起来就像这一行,这样你就知道怎么打了
我如何显示标签,让人们知道该输入什么?
我在我的网站上有一个允许使用HTML的输入表单,我正在尝试添加关于使用HTML标签的说明。我想让这文本
<strong>Look just like this line - so then know how to type it</strong>
但目前为止我只知道
看起来就像这一行,这样你就知道怎么打了
我如何显示标签,让人们知道该输入什么?
当前回答
你可以使用htmlspecialchars()
<?php
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new; // <a href='test'>Test</a>
?>
其他回答
你可以使用htmlspecialchars()
<?php
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new; // <a href='test'>Test</a>
?>
将<替换为<>和>
要在浏览器中显示HTML标记,可以用< xmp>和< / xmp>标记包围输出
你只需要编码<>s:
<strong>Look just like this line - so then know how to type it</strong>
你可以使用htmlentities当回显到浏览器,这将显示标签,而不是让html解释它。
请看这里http://uk3.php.net/manual/en/function.htmlentities.php
例子:
echo htmlentities("<strong>Look just like this line - so then know how to type it</strong>");
输出:
<strong>Look just like this line - so then know how to type it</strong>