Home > Backend Development > PHP Tutorial > PHP统一页面编码避免乱码问题_PHP

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

WBOY
Release: 2016-05-30 08:48:02
Original
762 people have browsed it

页面编码统一

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

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

2、html页面的编码,指的是这一行的设置:

代码如下:



3銆丳HP鎴杊tml鏂囦欢鏈

Related labels:
php
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