Home  >  Article  >  Backend Development  >  What to do if php reads garbled file content

What to do if php reads garbled file content

藏色散人
藏色散人Original
2021-04-01 09:43:102553browse

Solution to garbled file content read by php: 1. Check whether the default encoding is set in the HTML template header; 2. Change UTF-8 in charset=UTF-8 to the specified encoding format; 3. Set The encoding format of the uploaded file.

What to do if php reads garbled file content

The operating environment of this article: Windows7 system, PHP7.1 version, DELL G3 computer

Check whether the HTML template header is set to the default encoding

Column:

Put UTF-8 in charset=UTF-8 Change to the specified encoding format

What to do if php reads garbled file content

Set the PHP output encoding column: header("Content-Type: text/html; charset=UTF-8");

Change UTF-8 in charset=UTF-8 to the specified encoding format

What to do if php reads garbled file content

Set the encoding format of the uploaded file (the system default is ANSI)

For example: When saving Notepad, you can save as and set the UTF-8 encoding format to ensure that the encoding is consistent with the above encoding and there will be no garbled characters

What to do if php reads garbled file content

Notes

Note that the browser browsing encoding is consistent with the program encoding

[Recommended learning: PHP video tutorial]

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