Home  >  Article  >  php教程  >  PHP统一页面编码避免乱码问题,php页面编码乱码

PHP统一页面编码避免乱码问题,php页面编码乱码

WBOY
WBOYOriginal
2016-06-13 09:07:191136browse

PHP统一页面编码避免乱码问题,php页面编码乱码

页面编码统一

MySQL数据库编码、html页面编码、PHP或html文件本身编码要全部一致。

1、MySQL数据库编码:
建立数据库时指定编码(如gbk_chinese_ci),建立数据表、建立字段、插入数据时不要指定编码,会自动继承数据库的编码。
数据库连接时,也有编码,可以在连接完数据库后,执行mysql_query(‘SET NAMES gbk');//将gbk换成你的编码,如utf8。

2、html页面的编码,指的是这一行的设置:
复制代码 代码如下:

3銆丳HP鎴杊tml鏂囦欢鏈

Statement:
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