Home>Article>Backend Development> What to do if php fread Chinese garbled characters

What to do if php fread Chinese garbled characters

藏色散人
藏色散人 Original
2021-03-31 09:34:01 2007browse

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)

[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!

php
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