O'Reilly logo

Programming PHP, 3rd Edition by Peter MacIntyre, Kevin Tatroe, Rasmus Lerdorf

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

parse_url

Synopsis

mixed parse_url(string url)[, int component])

Returns an associative array of the component parts of url. The array contains the following values:

fragment

The named anchor in the URL

host

The host

pass

The user’s password

path

The requested path (which may be a directory or a file)

port

The port to use for the protocol

query

The query information

scheme

The protocol in the URL, such as “http”

user

The user given in the URL

The array will not contain values for components not specified in the URL. For example:

$url = "http://www.oreilly.net/search.php#place?name=php&type=book";
$array = parse_url($url);
print_r($array); // contains values for "scheme", "host", "path", "query",
                 // and "fragment"

If the component option is provided, then just that particular component of the URL will be returned.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required