Discussion: parseurl parses the URL and returns its components
Source: Internet
Author: User
This article analyzes the URL of parseurl and returns its components in detail. For more information, see
Parse_url (PHP 4, PHP 5)
Parse_url-parses the URL and returns its components
Description Array parse_url (string $ 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, and parse_url () tries to parse them correctly as much as possible.
Parameters Url
URL to be parsed
Return value
For URLs that are seriously unqualified, parse_url () may return FALSE and issue E_WARNING. Otherwise, an associated array is returned, which consists of (at least one ):
Scheme-such as http
Host
Port
User
Pass
Path
Query-question mark? After
Fragment-after the hash symbol #
Example Example 2369. parse_url () $ Url = 'http: // username: password @ hostname/path? Arg = value # anchor ';
Print_r (parse_url ($ url ));
?>
The above example will output: Array ([scheme] => http [host] => hostname [user] => username [pass] => password [path] =>/path [query] => arg = value [fragment] => anchor)
Note Note: This function cannot be used for relative URLs.
Note: parse_url () is used to parse a URL instead of a URI. However, there is an exception to PHP backward compatibility. The file: // protocol allows three diagonal lines (file :///...). None of the other protocols can.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.