Home  >  Article  >  Backend Development  >  Summary of commonly used url processing functions in php, phpurl function_PHP tutorial

Summary of commonly used url processing functions in php, phpurl function_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:13:39961browse

A summary of commonly used url processing functions in php, phpurl function

The example in this article summarizes several url encoding parsing functions in php, such as parse_url, rawurldecode, rawurlencode, urldecode, urlencode. Share it with everyone for your reference. The specific usage is as follows:

Let’s look at the introduction and examples: parse_url($str url);

Convert the url into an array: print_r(parse_url("www.jb51.net")); Parse the url and output the returned array, and restore the url special format string to a normal string.

Syntax: string rawurldecode(string str);

Return value: string

Function type: encoding processing

Content description: This function decodes a string from the string special format of the URL into a normal string. For detailed encoding and decoding information and specification files, please refer to rfc 1738. The code is as follows:

Copy code The code is as follows:
echo rawurldecode('foo%20bar%40baz'); //Output foo bar@baz
string rawurlencode ( string str )

Returns a string in which all non-alphanumeric characters except -_. are replaced with a percent sign (%) followed by two hexadecimal digits, which is the encoding described in RFC 1738, It is to protect the literal characters from being interpreted as special URL delimiters, and to protect the URL format from being messed up by the transmission media, like some mail systems, when using character conversion, for example, if you want to use ftp in the URL Contains password:

Copy code The code is as follows:

$str="http://www.bkjia.com"; //Define 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"; //Define string
$result=urlencode($str); //Encode the specified string
echo $result; //Output result

I hope this article will be helpful to everyone’s PHP programming.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/914058.htmlTechArticleA summary of commonly used url processing functions in php, phpurl function This article summarizes several url encoding parsing functions in php. Such as parse_url, rawurldecode, rawurlencode, urldecode, urlencode. Share to...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn