Home  >  Article  >  Backend Development  >  How to solve the problem of garbled Chinese question marks in PHP

How to solve the problem of garbled Chinese question marks in PHP

藏色散人
藏色散人Original
2020-08-31 10:32:544596browse

Solutions to garbled Chinese question marks in php: 1. Set the page header to "header('Content-Type: text/html; charset=UTF-8');"; 2. Set the character set to UTF8; 3. Set the Chinese field sorting rule to "utf8_general_ci".

How to solve the problem of garbled Chinese question marks in PHP

Recommended: "PHP Video Tutorial"

About the solution to the problem that php mysql Chinese is displayed as a question mark

1. Header setting (sent to the browser)

header('Content-Type:text/html; charset=UTF-8');

2. Character set setting (note UTF8)

mysql_query('set names utf8');

3. The database involves Chinese The field sorting rule is utf8_general_ci

4. Modify the page content encoding format in the editor and store it in UTF-8 format

5. This step is generally enabled by default, but if the previous four steps If everything is correct and there is still a question mark display in Chinese, you need to check this step

Find and open my.ini in the mysql installation directory mysql\bin

Check whether character_set_server is equal to utf8 and the front The # (comment) should be removed

The above is the detailed content of How to solve the problem of garbled Chinese question marks in PHP. For more information, please follow other related articles on the PHP Chinese website!

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
Previous article:How to install php5.4Next article:How to install php5.4