PHP » PYTHON |
login |
register |
about
|
PYTHON parse_url
is this article helpful?
|
Python replacement for PHP's parse_url
[
edit
| history
]
#2.x import urlparse print urlparse.urlparse('[url]http://www.cwi.nl:80/%7Eguido/Python.html[/url]') #3.x import urllib.parse print urllib.parse.urlparse('[url]http://www.cwi.nl:80/%7Eguido/Python.html[/url]') parse_url(PHP 4, PHP 5) parse_url — Parse a URL and return its components DescriptionThis function parses a URL and returns an associative array containing any of the various components of the URL that are present. This function is not meant to validate the given URL, it only breaks it up into the above listed parts. Partial URLs are also accepted, parse_url() tries its best to parse them correctly. Parameters
Return ValuesOn seriously malformed URLs, parse_url() may return FALSE and emit a E_WARNING. Otherwise an associative array is returned, whose components may be (at least one):
If the component parameter is specified a string is returned instead of an array. Changelog
Examples
Example #1 A parse_url() example
<?phpThe above example will output:
Array
(
[scheme] => http
[host] => hostname
[user] => username
[pass] => password
[path] => /path
[query] => arg=value
[fragment] => anchor
)
/path
Notes
See Also
|
more
Recently updated
more
Most requested
|