How to solve the problem of garbled Chinese characters displayed in php get

藏色散人
Release: 2023-03-09 22:10:01
Original
1840 people have browsed it

php get solution to display garbled Chinese characters: first open the corresponding code file; then set "header("Content-type: text/html; charset=utf-8"); in the list.php page; "That's it.

How to solve the problem of garbled Chinese characters displayed in php get

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

The example of this article describes how PHP uses get to obtain the appearance of Chinese characters in the url The solution to garbled characters. Share it with everyone for your reference. The specific method is as follows:

1. Question:

Originally planned to use it this way

The code is as follows:

[查看辖区动态]
Copy after login

The result obtained on the list.php page is— – Check [Jurisdiction Dongyi]

At first, I guessed that the encoding of the Chinese character "state" conflicted with something, so the code appeared garbled.

2. Solution:

Use:

The code is as follows:

Then use the

code like this on the list.php page As follows:

Copy after login

There will be no garbled characters and abnormal transmission.

Note that the encoding of the receiving GET page here needs to be consistent with the sending end!

About the string urlencode (string $str) function

This function facilitates encoding a string and using it in the request part of the URL, and it also facilitates passing variables to the next page.

Example 1 urlencode()

The code is as follows:

'; ?>
Copy after login

Example 2 urlencode() and htmlentities()

The code is as follows:

'; ?>
Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to solve the problem of garbled Chinese characters displayed in php get. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!