Home > Article > Backend Development > What to do if php fread Chinese garbled characters
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.
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)
[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!