Home > Backend Development > PHP Tutorial > PHP uses get to solve the problem of garbled Chinese characters in URL, geturl_PHP tutorial

PHP uses get to solve the problem of garbled Chinese characters in URL, geturl_PHP tutorial

WBOY
Release: 2016-07-13 10:14:13
Original
1007 people have browsed it

PHP uses get to solve the problem of garbled Chinese characters in the URL, geturl

The example in this article describes the solution to the garbled Chinese characters in the URL obtained by PHP using get. Share it with everyone for your reference. The specific method is as follows:

1. Question:

I originally planned to use it this way

Copy code The code is as follows:

The result on the list.php page is--View [Jurisdiction Dongyi]
At first, I guessed that the encoding of the Chinese character "state" might conflict with something, so garbled characters appeared.

2. Solution:

Use:

Copy code The code is as follows:

Then use
like this on the list.php page
Copy code The code is as follows:

header("Content-type: text/html; charset=utf-8");
if($_GET['plate'])
echo $plate=urldecode($_GET['plate']);
?>

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 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()

Copy code The code is as follows:
echo '';
?>

Example 2 urlencode() and htmlentities()
Copy code The code is as follows:

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/910585.htmlTechArticlePHP uses get to get the url Chinese characters appear garbled solution, geturl This article tells the example of PHP using get to get the url Chinese characters appear The solution to garbled characters. Share it with everyone for your reference. Specific methods...
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