PHP page Chinese garbled analysis _ MySQL

Source: Internet
Author: User
PHP page Chinese garbled analysis bitsCN. the reason why comphp garbled: the square format of the page file (.html ,. php, etc.), html. the browser encoding method, MySql database transmission encoding method, and Apache character set specified in head.

There are several reasons for Chinese garbled characters on PHP pages. One is that the page encoding is not counted. The other is that no encoding is set in the database. The third is that there is a problem with apache encoding, the following two solutions are provided: page encoding is not uniform.
Most of the garbled characters are caused by inconsistent encoding methods. There are four major inconsistencies that may exist:
1. the format of the webpage file (.html,. php, etc)
2. specify the browser encoding method in html. head.
3. encoding for MySql database transmission
4. Apache character set

When a JS pop-up window is created on a page with only PHP code, if the pop-up window contains Chinese characters, garbled characters may occur,
Solution: one line of code:
Chinese garbled characters on the page

The code is as follows:
Header ("Content-Type: text/html; charset = utf-8 ");
The database is garbled
The code is as follows :. Mysql_query ('set NAMES utf8 ');
// The next step is to find or modify the data and add
?>
Note:
1. This code must be placed at the top of the file ,' 2. the charset value depends on the code of the entire website. if it is gb2312, enter gb2312. BitsCN.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.