Parse_url
(PHP 4, PHP 5)
parse_url-resolves the URL, returning its component description array parse_url (string $url)
This function resolves a URL and returns an associative array containing the various components that appear in the URL.
This function is not used to verify the legality of a given URL, but to decompose it into the sections listed below. An incomplete URL is also accepted, andParse_url () tries to parse it as correctly as possible. Parameters
Url
The URL return value to resolve
For severely unqualified URLs,parse_url () may return FALSE and emit e_warning. Otherwise, an associative array is returned with a component (at least one): scheme-such as HTTP host port user Pass path query-at the question mark? After fragment-The example after the hash symbol #
example 2369. Parse_url () example <?php
$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] => arg=value
[Fragment] => anchor
)
Notes
Note: This function cannot be used for relative URLs.
Note: Parse_url () is specifically used to resolve URLs rather than URIs. However, there is an exception to the need to comply with PHP's backward compatibility, which allows three slashes (file:///...) for the file://protocol. )。 No other agreement can do that.