我希望在没有执行html的情况下回复以下内容:
<?php echo 'Allowable tags: <a><b>'; ?>
我该怎么做?
答案 0 :(得分:3)
echo 'Allowable tags: <a><b>';
答案 1 :(得分:3)
使用htmlentities会起作用:
<?php echo 'Allowable tags: ' . htmlentities('<a><b>'); ?>
答案 2 :(得分:0)
使用PHP htmlentities()将特殊字符转换为html实体,如下所示:
<?php echo htmlentities('Allowable tags: <a><b>'); ?>
答案 3 :(得分:0)
您可以使用HTML转义字符...
答案 4 :(得分:0)
htmlspecialchars - 将特殊字符转换为HTML实体。
<?php echo htmlspecialchars('Allowable tags: <a><b>'); ?>
输出HTML:
Allowable tags: <a><b>
见:
允许的标签:&lt; a&gt;&lt; b&gt;