Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the problem of garbled code of fread function in php

Shulou Source: shulou.com Published: 2022-06-03 11:35:50 10月04日 Update

This article mainly introduces how to solve the problem of garbled code of fread function in php. It is very detailed and has certain reference value. Interested friends must finish reading it.

Php fread function garbled solutions: 1, read the file directly through the fread function; 2, read the content through the "iconv ('gbk',' utf-8', $data)" method to transcode.

This article operating environment: Windows7 system, PHP7.1 version, Dell G3 computer

Problem description:

Php, through the fread function to read the file directly, the file content if encountered in Chinese, there will be garbled problem, how to solve this?

Solution:

Try to transcode the content after reading it.

Iconv ('gbk',' utf-8', $data)

Related introduction:

Iconv_get_encoding-gets the internal configuration variables of the iconv extension

Iconv_mime_decode_headers-decode multiple MIME header fields at once

Iconv_mime_decode-Decoding 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 the character count of 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-intercepts the portion of a string

Iconv-the string is converted according to the required character encoding

Ob_iconv_handler-converts character encodings with an output buffer handler

These are all the contents of this article entitled "how to solve the problem of garbled codes of fread functions in php". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Characters functions content garbled problems strings files encodings methods fields articles one-off values interests variables multiple guys buddies methods more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi NVidia MySQL OPPO Reno Microsoft