php 输出html 代码不解析怎么办?

php echo html的内容被解析了,是怎么回事呢,如图

php 输出html 代码不解析怎么办


 

<?php
header('Content-Type:text/plAIn;charset=utf-8'); echo "helloword"; echo "<hr>";
?>

检查之后是因为header(‘Content-Type:text/plain;charset=utf-8’);这一句代码影响的。
在这里要区分一下text/html和text/plain:text/html是以html的形式输出,比如就会在页面上显示一个文本框,而以plain形式就会在页面上原样显示这段代码

那么修改方式能有两种

1、用PHP设置编码


 

<?php
header("Content-type: text/html; charset=utf-8");
echo "<a href='http://s.jf3q.com'>helloword</a>"; echo "<hr>";
?>

2.用meta标签


 

<meta charset="UTF-8">
<?php
echo "helloword"; echo "<hr>";?>

php 输出html 代码不解析怎么办

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。