Home >Backend Development >PHP Problem >What to do if gbk encodes Chinese garbled characters under php

What to do if gbk encodes Chinese garbled characters under php

coldplay.xixi
coldplay.xixiOriginal
2020-08-06 13:13:184044browse

The solution to the Chinese garbled code in gbk encoding under php: first check the web page encoding, the code is [document.characterSet]; then convert the encoding from gbk to [utf-8], the code is [$contents=mb_convert_encoding(( $content】.

What to do if gbk encodes Chinese garbled characters under php

##Solution to Chinese garbled code in gbk encoding under php:

1. Check the web page encoding

Open the browser console to view the encoding

document.characterSet

2. Convert encoding

Convert from gbk to utf-8

$结果字符串 = mb_convert_encoding($原字符串, "目标便编码","原编码");
$contents = mb_convert_encoding($contents, "utf-8","gbk");

Related learning recommendations:

php programming(video)

The above is the detailed content of What to do if gbk encodes Chinese garbled characters under 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