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
Release: 2023-03-03 22:02:01
Original
4045 people have browsed it

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
Copy after login

2. Convert encoding

Convert from gbk to utf-8

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template