Home > Backend Development > PHP Problem > Chinese garbled code in php query table

Chinese garbled code in php query table

Release: 2023-02-28 09:44:02
Original
2775 people have browsed it

Chinese garbled code in php query table

Solution to Chinese garbled Chinese php query table:

1. First, you must figure out the sorting rules (encoding method) of your database, tables, and fields.

2. Use in php

$charset=mysqli_character_set_name($con);  //返回数据库默认字符集的编码utf8
echo "默认字符集为: " . $charset;
Copy after login

3. The encoding rules of the php header should be consistent with the database

header("Content-type:text/html;charset=utf8");//字符编码设置
Copy after login

4. The encoding rules of the html page should also be consistent

<meta http-equiv="Content-Type" content="text/html; charset=utf8">
Copy after login

Recommended: php server

The above is the detailed content of Chinese garbled code in php query table. For more information, please follow other related articles on the PHP Chinese website!

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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template