PHP common URL Processing function summary, Phpurl function _php Tutorial

Source: Internet
Author: User
Tags rfc alphanumeric characters

PHP common URL Processing function Summary, Phpurl function


This paper summarizes several parsing functions of URL encoding in PHP, such as Parse_url, Rawurldecode, Rawurlencode, UrlDecode, UrlEncode. Share it for everyone's reference. The specific usage is as follows:

The following is an introduction and an example: Parse_url ($str URL);

Convert URL to array: Print_r (Parse_url ("www.jb51.net")); Resolves the URL and outputs the returned array, and the URL-specific format string is restored to a normal string.

Syntax: string rawurldecode (String str);

return value: String

Function type: Encoding processing

Description: This function decodes the string, from the URL of the special format of the string to the ordinary string, the detailed encoding and decoding information and specification file can refer to RFC 1738, the code is as follows:
Copy the Code code as follows: Echo rawurldecode (' Foo%20bar%40baz '); Output Foo Bar@baz
String Rawurlencode (String str)
Returns a string, in addition to-_, in this string. All non-alphanumeric characters will be replaced with a percent (%) followed by a two-digit hexadecimal number, which is the encoding described in RFC 1738 to protect the literal character from being interpreted as a special URL delimiter, while protecting the URL format from transmitting media, like some messaging systems, Use character conversions when confusing, for example, if you want to include a password in the FTP URL:

Copy the Code code as follows:
$str = "http://www.bkjia.com"; Defining strings
$result =rawurlencode ($STR); Encodes the specified string
echo $result;
/*
UrlDecode ()
URL decoding
*///output result
$str = "Http%3a%2f%2fwww.jb51.net";
$result =urldecode ($STR);
echo $result;
/*
UrlEncode ()
URL encoding
*/
$str = "http://www.bkjia.com"; Defining strings
$result =urlencode ($STR); Encodes the specified string
echo $result; Output results
I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/914058.html www.bkjia.com true http://www.bkjia.com/PHPjc/914058.html techarticle PHP Common URL processing function Summary, Phpurl function This article summarizes several kinds of URL code parsing functions in PHP, such as Parse_url, Rawurldecode, Rawurlencode, UrlDecode, UrlEncode. Share to ...

  • 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.