php中文乱码怎么办如何让浏览器自动识别utf-8_PHP

WBOY
Release: 2016-06-01 11:57:35
Original
703 people have browsed it

刚开始学习php的朋友可能经常遇到问题,就是调试的时候经常显示乱码
每次打开浏览器都要改下编码,很麻烦,
有没有方法让浏览器自动识别utf-8呢?
解决的方法很简单 就是在php里加一句header

例:

header("Content-type: text/html; charset=utf-8");

echo '我是初学者';

不错需要注意的一点是
header("Content-type: text/html; charset=utf-8");
这一句前不能向页面输出任何内容,意思是不能使用echo等语句,也不能输出html标签或文字

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!