PHP urlencode and rawurlencode Tutorial _php Tutorial

Source: Internet
Author: User
PHP urlencode and Rawurlencode tutorial Rawurlencode
(PHP 4, PHP 5)

Rawurlencode-URL encoding based on RFC 1738

Describe
String Rawurlencode (String $str)
Encode a specific string according to the» RFC 1738.

Parameters

Str
Encode the URL.


return value
Returns all non-alphanumeric characters in a string except for-_. is replaced with a percent sign (%) symbol followed by two hexadecimal digits. This is the encoding description» RFC 1738 for the protection of literal characters that are interpreted as special URL-delimited and protected URLs that are corrupted by the transmission media conversion and nature (such as some e-mail systems).

Instance

For example # 1 includes a password for the FTP URL

$a = Explode (' & ', $QUERY _string);
$i = 0;
while ($i < count ($a)) {
$b = Split (' = ', $a [$i]);
Echo ' Value for parameter ', Htmlspecialchars (UrlDecode ($b [0])),
' Is ', Htmlspecialchars (UrlDecode ($b [1])), "
n ";
$i + +;
}
?>

For UrlEncode
(PHP 4, PHP 5)

Make UrlEncode-URL encoded string

Describe
String UrlEncode (String $str)
This handy encoding string is used as part of the query URL, as a convenient way to pass the next page of the variable.

Parameters

Str
String encoding.


return value
Returns all non-alphanumeric characters in a string except for-_. is replaced with a percent sign (%) symbol followed by two hexadecimal digits and a space encoded as a plus sign (+). This is the same encoding method from the published data encoded in the WWW form, which is the same way in the application/x www form of the urlencoded media type. This differs from the reference» RFC 1738 encoding (see Rawurlencode ()), for historical reasons, the space encoded as a plus sign (+) sign.

Instance

Example # 1 For an example of UrlEncode ()

Echo ';
?>


Example #2 UrlEncode () and htmlentities () Example

$query _string = ' foo= '. UrlEncode ($foo). ' &bar= '. UrlEncode ($bar);
Echo ';
?>

http://www.bkjia.com/PHPjc/630888.html www.bkjia.com true http://www.bkjia.com/PHPjc/630888.html techarticle php urlencode with rawurlencode tutorial Rawurlencode (PHP 4, PHP 5) rawurlencode-URL encoding based on RFC 1738 describes the string Rawurlencode (string $st R) encoding specific ...

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