php页面怎么设置utf-8
2022-12-02 09:01:16
93
{{single.collect_count}}

php页面设置utf-8的方法:首先打开相应的PHP页面文件;然后在响应报文中设置content-type字段,如在php文件中添加“header("Content-Type:text/html;charset=utf-8");”即可。

php入门到就业线上直播课:进入学习
Apipost = Postman + Swagger + Mock + Jmeter 超好用的API调试工具:点击使用

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

PHP设置页面字符集utf-8

这个需要使用header()函数,这个函数的功能就是设置响应报文内容的。

想让浏览器按utf-8编码处理页面,就需要在响应报文中设置content-type字段。

content-type,用于定义网络文件的类型和网页的编码,决定文件接收方将以什么形式、什么编码读取这个文件。

在PHP文件中插入下边这行代码就可以了,不过要注意在header()函数之前不能有任何输出。

header("Content-Type:text/html;charset=utf-8");
登录后复制

【推荐学习:《PHP视频教程》】

以上就是php页面怎么设置utf-8的详细内容,更多请关注php中文网其它相关文章!

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}