关于PHP乱码有关问题

WBOY
Release: 2016-06-13 10:09:08
Original
639 people have browsed it

关于PHP乱码问题
用easyeclipse for php编程,默认编码是gbk,可以显示中文。
网上有很多编写好的类,直接拿过来用,发现都是UTF-8编码的,把整个程序的编码方式改成UTF-8后,类中的汉子部分在
eclipse里面就能显示了,但是在浏览器显示的还是乱码啊,这种编码问题怎么解决呢,有没有好的解决方案或者建议。在加上数据库那一套,出现乱码的可能性就更大了

------解决方案--------------------
把浏览器的编码也改为utf-8 。为了省去每次改浏览器的编码。在行首加上header("Content-Type:text/html;charset=utf-8");

如果还牵扯到数据。则数据库编码也为utf8
------解决方案--------------------
建议以后开发都用utf-8吧,将来如果有机会到linux下或者将文件放到linux主机上的时候能少掉很多麻烦。
特别是跟json ajax之类的数据传递的时候.
我已经吃过这个苦头了,开始使用gbk 后来发现很多地方都要去考虑编码的问题。

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!