Home > Article > Backend Development > What to do if php fread is garbled?
php fread garbled solution: first read the file directly through the fread function; then transcode the read content through the "iconv('gbk', 'utf-8', $data)" method That’s it.
Recommendation: "PHP Video Tutorial"
In php, read the file directly through the fread function, and the file content If you encounter Chinese, garbled characters will appear. How to solve this problem?
Solution:
Try transcoding the content after reading it out
iconv('gbk', 'utf-8', $data)
The above is the detailed content of What to do if php fread is garbled?. For more information, please follow other related articles on the PHP Chinese website!