Summary of common php url processing functions, phpurl functions. Summary of common php url processing functions. phpurl functions in this article examples summarize several url encoding parsing functions in php, such as parse_url, rawurldecode, rawurlencode, urldecode, and urlencode. summary of common php url processing functions, phpurl functions
This example summarizes several url encoding parsing functions in php, such as parse_url, rawurldecode, rawurlencode, urldecode, and urlencode. The usage is as follows:
The following describes the introduction and examples: parse_url ($ str url );
Convert a url to an array: print_r (parse_url ("www.jb51.net"). parse the url and return an array. the url-specific format string is restored to a normal string.
Syntax: string rawurldecode (string str );
Return value: string
Function type: encoding
Description: This function decodes a string from the special format of the url string to a normal string. for detailed encoding and decoding information and specification files, refer to rfc 1738. the code is as follows:
The code is as follows:
Echo rawurldecode ('foo % 20bar % 40baz'); // output foo bar @ baz
String rawurlencode (string str)
Returns a string -_. all other non-alphanumeric characters will be replaced with a semicolon (%) followed by two hexadecimal numbers, which is the encoding described in rfc 1738, it is to protect the original characters from being interpreted as special url delimiters, and protect the url format to prevent them from being transmitted to media. for example, in some mail systems, character conversion is messy. for example, if you want to include the password in the ftp url:
The code is as follows:
$ Str = "http://www.bkjia.com"; // defines a string
$ Result = rawurlencode ($ str); // Encode 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"; // defines a string
$ Result = urlencode ($ str); // Encode the specified string
Echo $ result; // output result
I hope this article will help you with PHP programming.
Examples in this article summarize several url encoding parsing functions in php, such as parse_url, rawurldecode, rawurlencode, urldecode, and urlencode...