URL string function encoded by PHP: urlencode

Source: Internet
Author: User
Tags form post alphanumeric characters
Urlencode (PHP4, PHP5) urlencode & nbsp; & mdash; & nbsp; URL string description string & nbsp; urlencode & nbsp; (& nbsp; string & nbsp; $ str & nbsp;) This function allows you to encode a string and use it in the request section of the URL.

(PHP 4, PHP 5)

Urlencode? -? Encode a URL string

Description string? Urlencode? (? String? $str?)

This function allows you to encode a string and use it in the URL request section. It also allows you to pass variables to the next page.

The string to be encoded.

Return value

Returns a string, except?-_.? All other non-alphanumeric characters will be replaced with a semicolon (%) Followed by two hexadecimal numbers, and space is encoded as the plus sign (+). This encoding method is the same as that for WWW form POST data?Application/x-www-form-urlencoded? The media type encoding method is the same. For historical reasons, this encoding is used to encode spaces as the plus sign (+) and RFC1738 encoding (see? Rawurlencode () is different.


Example #1?Urlencode ()? Example


Example #2?Urlencode ()? And? Htmlentities ()? Example

Other functions
  • Urldecode ()? -Decode the encoded URL string.
  • Htmlentities ()? -Convert all adaption characters to HTML Character encoding
  • Rawurlencode ()? -Encode the URL according to RFC 1738
  • Rawurldecode ()? -Decode the encoded URL string
  • ?? RFC 3986
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.