It completely solves the issue of PHP and MySQL garbled characters, because some people often ask this question recently, so I will simply summarize and send an article here, and then let him see it directly on his website. it is annoying to answer the same question many times.
The solution is very simple, is to unified encoding, if we use UTF-8 encoding:
1. Create a databaseIf you want to publish this article, please indicate the location, without the right to publish the copyright, I do not like to see that kind of website my work does not indicate the person qq9256114
When the database is created, the encoding is set to utf8 in a unified manner. When you create a data table or add a field, do not set encoding again.
2. Add page Encoding
PHP
Header ('content-type: text/html; charset = UTF-8 ');
Html
<Meta http-equiv = "Content-Type"Content= "Text/html; charset = UTF-8"/>
<Title> must be placed before the title </title>If you want to publish this article, please indicate the location, without the right to publish the copyright, I do not like to see that kind of website my work does not indicate the person qq9256114
3. When establishing a connection with a database
Mysql_query ("set names 'utf8 '");
Mysql_select_db ('table name', $ this-> conn) or die ('Open the databaseError, Please check the database exists! ');
4. When saving the PHP File
Taking editplus as an example, you must select UTF-8 as the encoding when saving.