Home  >  Article  >  Backend Development  >  What to do if php insert into garbled characters

What to do if php insert into garbled characters

藏色散人
藏色散人Original
2020-07-25 09:08:182321browse

Solution to php insert into garbled characters: 1. Before connecting to the database, add "mysql_query("SET NAMES UTF8");"; 2. Add "content-type: text/html;" to the header of the html page. charset=UTF-8;".

What to do if php insert into garbled characters

php insert into garbled characters:

Before connecting to the database, mysql_query("SET NAMES UTF8") has been added;

HTML page header, add header("content-type:text/html; charset=UTF-8");

The encoding of all pages and files are unified. Think about the places where you can set the encoding. The meta in the html head also needs to be set. You can open the template file, or related html files, or php files, use editing software, and save it in utf8 format.

Recommended: "PHP Tutorial"

The above is the detailed content of What to do if php insert into garbled characters. 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