What to do if php fread Chinese garbled characters

藏色散人
Release: 2023-03-09 08:42:01
Original
2188 people have browsed it

php fread Chinese garbled solution: first create a PHP sample file; then read the file through the fread function; finally pass the content through "iconv('gbk', 'utf-8', $data)" Just transcode.

What to do if php fread Chinese garbled characters

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

Specific questions:

In PHP, files are read directly through the fread function. If the file content encounters Chinese characters, the problem will be garbled. How to solve this problem?

Solution:

Transcode the content after reading it out

iconv('gbk', 'utf-8', $data)
Copy after login

[Recommended learning: PHP video tutorial]

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