What to do if the php fread function is garbled

藏色散人
Release: 2023-03-12 17:26:02
Original
2572 people have browsed it

php fread function garbled solution: 1. Read the file directly through the fread function; 2. Pass the read content through the "iconv('gbk', 'utf-8', $data)" method Just transcode.

What to do if the php fread function is garbled

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

What should I do if the php fread function is garbled?

Problem description: In

#php, the file is read directly through the fread function. If the file content encounters Chinese, garbled characters will appear. How to solve this problem? solve?

Solution:

Try transcoding the content after reading it out

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

Related introduction:

iconv_get_encoding — Get the internal configuration variables of the iconv extension

iconv_mime_decode_headers — Decode multiple MIME header fields at once

iconv_mime_decode — Decode a MIME header field

iconv_mime_encode — Composes a MIME header field

iconv_set_encoding — Sets the current setting for character encoding conversion

iconv_strlen — Returns character count statistics for a string

iconv_strpos — Finds position of first occurrence of a needle within a haystack

iconv_strrpos — Finds the last occurrence of a needle within a haystack

iconv_substr — Intercept part of the string

iconv — Convert the string according to the required character encoding

ob_iconv_handler — Convert character encoding with output buffer handler

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What to do if the php fread function is garbled. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!