Url: several common functions: parse_url () this function parses a URL and returns an associated array, including the various components in the URL. This function is not used to verify the validity of a given URL, but is used to separate it into the parts listed below. Incomplete URLs are also accepted, and parse_url () tries to parse them correctly as much as possible. & Nbsp; $ _ urlwww.baidu.com
Parse_url ()
This function parses a URL and returns an associated array, which contains various components in the URL.
This function is not used to verify the validity of a given URL, but is used to separate it into the parts listed below. Incomplete URLs are also accepted,Parse_url ()Will try to correctly parse it as much as possible.
$ _ Url = "http://www.baidu.com/web? Id = 15 & page = 5 "; $ _ par = pares_url ($ _ url); var_dump ($ _ par );
Output result:
array(4) { ["scheme"]=> string(4) "http" ["host"]=> string(13) "www.baidu.com" ["path"]=> string(4) "/web" ["query"]=> string(12) "id=15&page=5"}
Parse_str ()
Parses a string into multiple variables.
Parse_str ($ _ par ['query'], $ _ query); var_dump ($ _ query); output result: array (2) {["id"] => string (2) "15" ["page"] => string (1) "5 "}
Http_bustm_query ()
Generate a URL-encode request string using the given correlated (or subscript) array.
Unset ($ _ query ['Page']); // clear page var_dump (http_build_query ($ _ query); output: string (5) "id = 15"
It is used to parse, split, and reorganize URL strings.