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

What to do if the php file saved is garbled

藏色散人
Release: 2023-03-02 13:14:02
Original
2717 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template