Home  >  Article  >  Backend Development  >  What to do if the php file saved is garbled

What to do if the php file saved is garbled

藏色散人
藏色散人Original
2020-07-13 10:12:382646browse

Solution to garbled php files saved: 1. Set the encoding of the php file itself to match the encoding of the web page; 2. Add "header("Content-Type: text/html;charset= to the PHP page gb2312")"; 3. Set the encoding format of all files to ANSI.

What to do if the php file saved is garbled

##PHP file garbled code (gb2312 saved, but input utf-8)

Problem :

The file has been saved with gb2312, but it still displays garbled characters.

After that, joining still didn’t work.

Solution:

1. The encoding of the php file itself and the encoding of the web page should match

2. If you want to use gb2312 encoding, then php must output the header: header(" Content-Type: text/html; charset=gb2312"), add a static page, the encoding format of all files is ANSI, you can open it with Notepad, save as, select the encoding as ANSI, overwrite the source file.

Note: The difference is between static pages and dynamic pages!

For more related knowledge, please visit

PHP Chinese website!

The above is the detailed content of What to do if the php file saved is garbled. 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