Home  >  Article  >  Backend Development  >  How to solve the problem of garbled display of traditional Chinese characters in php

How to solve the problem of garbled display of traditional Chinese characters in php

藏色散人
藏色散人Original
2021-10-25 09:58:453167browse

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.

How to solve the problem of garbled display of traditional Chinese characters in php

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!

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