Home>Article>Backend Development> What should I do if php displays traditional Chinese garbled characters?

What should I do if php displays traditional Chinese garbled characters?

藏色散人
藏色散人 Original
2021-09-13 10:30:05 3156browse

Solution to the problem that php displays Traditional Chinese garbled characters: 1. Open the corresponding PHP code file; 2. Use "mb_convert_encoding($str,'gbk','utf-8');" to solve the problem of Traditional Chinese characters appearing on the web page The interface displays garbled characters.

What should I do if php displays traditional Chinese garbled characters?

The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer

What should I do if php displays traditional Chinese garbled characters?

php: Function to solve the problem of simplified and traditional Chinese characters displaying garbled characters in the web interface

Solution to the problem of simplified and traditional Chinese characters displaying garbled characters in the web interface:

mb_convert_encoding($str,'gbk','utf-8');

gbk is Traditional Chinese encoding, gb2312 is simplified Chinese encoding. But gbk contains gb2312, so if the array contains traditional Chinese and simplified characters, just use gbk to convert.

Related introduction:

mb_convert_encoding function is PHP internal multi-byte string encoding conversion function, which can be used for encoding conversion when necessary, such as: solving the problem in GB2312 The problem of garbled Chinese characters caused by using Ajax in a coding environment. Supports almost all encodings, and the version supports PHP 4 >= 4.0.6, PHP 5.

Syntax:

mb_convert_encoding ( string str, string to_encoding [, mixed from_encoding] )

string str is the string that needs to be encoded and converted;

string to_encoding specifies the conversion to a certain encoding, such as: gb2312, gbk, utf-8, etc. ;

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What should I do if php displays traditional Chinese garbled characters?. For more information, please follow other related articles on the PHP Chinese website!

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