When we do web pages, we often encounter Chinese garbled characters on the pages. how can we solve this problem? The following is a small Editor of Wangguan home, which will share with you four common html web page garbled issues and solutions, if you need a friend, you can refer to the code garbled when my colleague opened the webpage last week. my colleague was confused and did not know how to solve the problem, below is a small editor to take the time to sort out common html webpage garbled issues and solutions to share with you.
In fact, there are several main reasons for webpage garbled text. The following provides a solution.
1. encoding of HTML characters
This problem is common and the most obvious and easy to solve.
On the webpageAdd:
You can.
2. PHP character encoding problems
This is similar to the above.
Add:
header("Content-type:text/html;charset=utf8");
You can.
3. file encoding
Not only are our content encoded, but also the file itself.
Use Notepad ++ to open a file and you can see the content displayed in the lower right corner.
It is the encoding of the file.
You can use the "format" on the Notepad ++ toolbar to convert and encode our files.
4. database coding problems
MySQL data is latin1 encoded by default, so the webpage may be garbled without notice.
Use root to enter the database,
Enter show variables like 'character %'
We can see that
Character_set_client
Character_set_connection
Character_set_database
Character_set_filesystem
Character_set_results
Character_set_server
Character_set_system
These seven values.
The set names ut8 command can
Character_set_client
Character_set_connection
Character_set_results
Set these three parameters to utf8.
Therefore, when creating a database in MySQL, set the character set and sorting rule to utf8 ,.
Then, in the file connecting to the database, perform mysql_query ("set names UTF8") on the database ").
This ensures that the webpage will not be garbled.
The above are four common html webpage garbled issues and solutions shared by Alibaba Cloud Xiaobian. I hope you will like them.