[PHP]解决PHP和MySQL的中文乱码问题
PHP连接数据库的时候经常会出现中文乱码,一般只需要检查编码是否统一就可以解决乱码问题。 1.数据库的字符编码: 可以将将所有编码设置为UTF-8。这样在数据库中就能正常显示中文了, php Admin默认的就是UTF-8编码。 2.页面文件的 字符编码 : 在编辑器中右
PHP连接数据库的时候经常会出现中文乱码,一般只需要检查编码是否统一就可以解决乱码问题。
可以将将所有编码设置为UTF-8。这样在数据库中就能正常显示中文了,phpAdmin默认的就是UTF-8编码。
2.页面文件的字符编码:
在编辑器中右击,选择编码方式也为UTF8即可。
3.PHP的字符编码(重点):
加在页面文件的头部,需要包含在PHP中。
4.HTML的字符编码
5.查询编码:
在php文件中添加如下内容:
mysql_query("SET NAMES UTF8");

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools