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

php 输出html 代码不解析怎么办,第1张

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

php输出html代码不解析的解决办法:1、用PHP设置编码,代码如“header("Content-type:...charset=utf-8")”;2、用meta标签设置编码,代码如“<meta charset="UTF-8">”。

本文 *** 作环境:Windows7系统、PHP7.1版,DELL G3电脑

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

php echo 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视频教程》

以上就是php 输出html 代码不解析怎么办的详细内容,

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/679614.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-20
下一篇 2022-04-20

发表评论

登录后才能评论

评论列表(0条)

保存