How to solve PHP Chinese garbled characters

Source: Internet
Author: User
How to solve PHP Chinese garbled characters ,. How to solve PHP Chinese garbled text, how to solve PHP Chinese garbled text Problem 1. how to solve Chinese garbled text in HTML 1. add UTF8 encoding (International encoding) to the head tag ): UTF-8 is how to solve PHP Chinese garbled problem,
How to solve PHP Chinese garbled characters

I. solutions to Chinese garbled characters in HTML
1. add UTF8 encoding (International code) to the head label: the UTF-8 is not country-specific, that is, it is independent of any language, any language can be used.

2, the file encoding stored as a UTF-8. Notepad, Editplus, and other editors can select encoding when saving files.

2. HTML and PHP hybrid page solution
In addition to the operations described in the first method, you also need to add the code at the top of the file:
Header ("Content-type: text/html; charset = utf-8 ");
?>

3. Chinese garbled characters on pure PHP pages (static data)
This only needs to add the following code at the beginning of the page, and then save the UTF-8 encoding file.
Header ("Content-type: text/html; charset = utf-8 ");
?>

4. Chinese garbled characters in PHP + Mysql
In addition to the operations described in the third point, you must add the database encoding before you query, modify, and add data. Furthermore, it is worth noting that the UTF8 here is different from the previous one, and there is no horizontal line in the middle.
Mysql_query ('set NAMES utf8 ');
// The next step is to find data or modify and add
?>

5. correctly display the Chinese name of the uploaded attachment

Find the file config. php in xampp/moodle,
Add $ CFG-> unicodedb = true; and then add $ CFG-> unicodecleanfilename = true;
So that the accessories uploaded by the lamp can display the Chinese name correctly.

6. garbled characters may be displayed during File upload in IE browser.

Lib/editor/htmlarea/coursefiles. php

The second line adds the following sentence: // you can use: set nu to display the row number.

@ Header ("Content-Type: text/html; charset = utf-8"); // This is the default UTF-8 encoding.

Coding, how to solve PHP Chinese garbled problem 1, solve the problem of Chinese garbled characters in HTML method 1, add UTF8 encoding in the head label (International code): UTF-8 is...

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.