Home > Article > Backend Development > What to do if php reads garbled file content
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.
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
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
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
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!