Home  >  Article  >  Backend Development  >  How to solve the problem of garbled characters on the PHP page

How to solve the problem of garbled characters on the PHP page

王林
王林Original
2019-09-16 17:58:364115browse

How to solve the problem of garbled characters on the PHP page

Check the problem of converting the HTML page to UTF-8 encoding
1. Add some code after the head and before the title

The order of

cannot be wrong, it must be after the head and before the title.

2. HTML file encoding problem

Click the editor menu: "File"->"Save As", you can see the encoding of the current file, make sure The file encoding is: UTF-8. If it is ANSI, the encoding needs to be changed to: UTF-8.
3. HTML file header BOM problem:
When converting a file from other encodings to UTF-8 encoding, sometimes a BOM tag is added at the beginning of the file. The BOM tag may cause the browser to display garbled characters when displaying Chinese characters.
How to delete this BOM tag:
1. You can open the file with Dreamweaver and resave it to remove the BOM tag!
2. You can open the file with EditPlus, and in the menu "Preferences"->"File"->"UTF-8 Identity", set it to: "Always delete signature", and then save the file. Remove the BOM tag!
3. WEB server UTF-8 encoding problem:
If you follow the steps listed above and still have Chinese garbled problems, please check the encoding of the WEB server you are using. question. If you are using Apache, please set charset in the configuration file to utf-8. If you are using Nginx, please set charset in nginx.conf to utf-8. Specifically find "charset gb2312;" or a similar statement and change it to: "charset utf-8;"

Recommended video tutorial: PHP video tutorial

The above is the detailed content of How to solve the problem of garbled characters on the PHP page. 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