This article mainly introduces the use of a Get URL of PHP to get URLs of Chinese characters garbled solution, is a lot of PHP programmers have encountered the problem, very practical value, the need for friends can refer to the next
In this paper, we describe a workaround for PHP to get the URL of Chinese characters garbled by using get. Share to everyone for your reference. Here's how:
First, the question:
Originally intended to use this
<a href= "list.php?plate= area dynamic" charset= "Utf-8" target= "main" >[view jurisdictions dynamic]</a>
Results are obtained on the list.php page-view [territory dynamic Yiwen]
At first it may be that the "state" of the Chinese character is in conflict with something, so garbled.
Second, the solution:
Use:
<a href= "list.php?plate=<?php Echo urlencode (" Jurisdiction dynamic ");? > "charset=" Utf-8 "target=" main ">[View]</a>
Then use it on the list.php page
<?phpheader ("content-type:text/html; Charset=utf-8 "), if ($_get[' Plate ')) echo $plate =urldecode ($_get[' Plate ']);? >
It will not be garbled and the transmission is not normal.
Note Here the receive Get page encoding needs to be consistent with the sending side!
About the string UrlEncode (string $str) function
This function makes it easy to encode a string and use it for the request part of the URL, and it also facilitates the passing of a variable to the next page.
Example 1 UrlEncode ()
<?phpecho ' <a href= ' mycgi?foo= ', UrlEncode ($userinput), ' > ';? >
Example 2 UrlEncode () and Htmlentities ()
<?php$query_string = ' foo= '. UrlEncode ($foo). ' &bar= '. UrlEncode ($bar); Echo ' <a href= ' mycgi? '. Htmlentities ($query _string). ' > ';? >
The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!