Solution to obtain URL with garbled Chinese characters in PHP_PHP Tutorial

WBOY
Release: 2016-07-13 17:00:14
Original
1011 people have browsed it

This article will introduce to you that when we submit a form, if the form uses the get method, then what we get using get will be garbled characters. Let me take a look at how to solve this problem.

I originally planned to use it this way

The code is as follows
 代码如下 复制代码

[查看辖区动态]

Copy code

[View Jurisdiction News]

The result obtained on the list.php page is - View [Jurisdiction Movement]
 代码如下 复制代码

" charset="utf-8" target="main">[查看]

I think it may be that the encoding of the Chinese character "state" conflicts with something, so. . .

 代码如下 复制代码

$plate=urldecode($_GET['plate']);

I found this solution online:

Use:

The code is as follows
Copy code

" charset="utf-8" target="main">[View]< ;/a>

 代码如下 复制代码

echo '';
?>

Then use this on the list.php page
 代码如下 复制代码

$query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar);
echo '';
?>

The code is as follows Copy code
$plate=urldecode($_GET['plate']);

There will be no garbled characters or abnormal transmission 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() Example
The code is as follows Copy code
echo ''; ?> Example #2 urlencode() and htmlentities() example
The code is as follows Copy code
$query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar);<🎜> echo ''; ?> http://www.bkjia.com/PHPjc/631260.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631260.htmlTechArticleThis article will introduce to you that when we submit the form, if the form uses the get method, then we use get to obtain What you get will be garbled characters. Let’s see how to solve this problem. ...
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