Get the App
SLTechnology News&Howtos  ›  Development  › 

Php shows how to deal with traditional garbled code

Shulou Source: shulou.com Published: 2022-06-03 15:23:07 10月01日 Update

Editor to share with you php shows how to deal with traditional garbled code, I hope you have something to gain after reading this article, let's discuss it together!

Php display traditional garbled solutions: 1, open the corresponding PHP code file; 2, through the "mb_convert_encoding ($str,'gbk','utf-8');" way to solve the problem of garbled display of traditional characters in the web interface.

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

What if php displays traditional garbled codes?

Php: a function to solve the garbled display of simplified and traditional characters in the web interface

Simplified and traditional Chinese characters are the solutions to display garbled in the web interface:

Mb_convert_encoding ($str,'gbk','utf-8')

Gbk is a traditional code and gb2312 is a simplified code. However, gbk contains gb2312, so if the array contains traditional and simplified characters, you can use the gbk transformation.

Related introduction:

The mb_convert_encoding function is a multi-byte string encoding conversion function within php, which can be converted when necessary, such as solving the problem of garbled Chinese characters caused by using Ajax in the GB2312 coding environment. Almost all encodings are supported, and the version supports PHP 4 > = 4.0.6 and PHP 5.

Syntax:

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

The string that string str needs to transcode

String to_encoding specifies the conversion to some kind of encoding, such as gb2312, gbk, utf-8, etc.

After reading this article, I believe you have a certain understanding of "how to deal with traditional garbled codes in php display". If you want to know more about it, welcome to follow the industry information channel. Thank you for your reading!

Tags: Traditional garbled coding traditional characters functions characters interfaces web pages strings methods environments simplified characters articles questions support codes methods situations bytes done Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Docker vpn macOS Microsoft