Home >Backend Development >PHP Problem >How to solve the problem of garbled display of traditional Chinese characters in php
Solution to php Traditional Chinese characters displaying garbled characters: 1. Open the corresponding PHP file; 2. Convert the character encoding through the "mb_convert_encoding" function.
The operating environment of this article: Windows7 system, PHP7.1 version, DELL G3 computer
How to solve php Traditional Chinese Display garbled code problem?
php function to solve the problem that simplified and traditional Chinese characters display garbled characters in the web interface
The solution for simplified and traditional Chinese characters to display 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.
Note: mb_convert_encoding - Convert character encoding
Description
string mb_convert_encoding ( string $str , string $to_encoding [, mixed $from_encoding = mb_internal_encoding() ] )
Convert the character encoding of string type str from optional from_encoding to to_encoding.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to solve the problem of garbled display of traditional Chinese characters in php. For more information, please follow other related articles on the PHP Chinese website!