Parse_url
(PHP 4, PHP 5)
parse_url-parse URL, return its components
description
Array Parse_url (string $url)
This function parses a URL and returns an associative array containing the various components that appear in the URL.
This function is not used to validate the legitimacy of a given URL, but to decompose it into the parts listed below. An incomplete URL is also accepted, and Parse_url () tries to parse it as correctly as possible.
Parameters
wr.
The URL to resolve
return value
A url,parse_url () that is severely unqualified may return FALSE and emit e_warning. Otherwise, an associative array is returned, with the component (at least one):
Scheme-such as HTTP
Host
Port
User
Pass
Path
Query-in question marks? After
Fragment-After hash symbol #
Example
Example 2369. Parse_url () example
$url = ' Http://username:password@hostname/path?arg=value#anchor ';
Print_r (Parse_url ($url));
?>
The example above will output:
Array (Scheme) + HTTP [host] + hostname [user] = username [pass] = password [path] +/path [query] =& Gt Arg=value [Fragment] = anchor)
notes
Note: This function cannot be used for relative URLs.
Note: Parse_url () is specifically used to parse URLs instead of URIs. However, there is an exception to the need for backward compatibility with PHP, which allows three slashes (file:///) for the file://protocol. )。 No other protocol can do that.
http://www.bkjia.com/PHPjc/327614.html www.bkjia.com true http://www.bkjia.com/PHPjc/327614.html techarticle Parse_url (PHP 4, PHP 5) parse_url-parses the URL and returns its component description array Parse_url (string $url) This function parses a URL and returns an associative array, contained in the u...< /c5>