Home  >  Article  >  Backend Development  >  PHP web page Chinese garbled code

PHP web page Chinese garbled code

尚
Original
2019-10-26 14:13:024905browse

PHP web page Chinese garbled code

Solution to Chinese garbled characters in PHP web pages:

Recommendation: php server

Method 1: Set the encoding in the php file Format, because the encoding format of the database is utf8, the encoding format of PHP is also utf8

PHP web page Chinese garbled code

Set the encoding method at the beginning of PHP, and also set the encoding format before SELECT

Method 2: WINDOWS, WIN R open the console and find the bin directory of mysql

Enter mysql

PHP web page Chinese garbled code

##Use the show variables command

mysql> show variables like 'char%';

PHP web page Chinese garbled code

You can see that the default encoding of character_set_database is latin1, we now want to change it to utf8

Find the my.ini file under Mysql

Add default-character-set=utf8 under client

PHP web page Chinese garbled code##Add character-set under mysqld -server=utf8

Then restart the APCHE server and check the mysql encoding according to the previous command line

The above is the detailed content of PHP web page Chinese garbled code. 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