php using Get Get URL The solution of garbled characters problem

Source: Internet
Author: User
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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.