Parsing a URL with parse_url

Quest:

Generate a list containing the parsing
URL by its properties: protocol, port,
host, path, resource, query words, and
print out as
“Name/Value”

I’m using the parse_urlfunction, but I don’t understand a bit, I just discovered PHP. Can someone explain to me about URL parsing: what is “protocol, port, host, path, resource, query words”?
The protocol, it seems, is http, the host is understandable, I’m lost about the rest. They can be output using parse_urland what should be the address? If possible, please explain with examples.

By given URL

http://www.scriptol.com/how-to/parsing-url.php#content

It gives me only

Array ( [scheme] => http [host] =>
www.scriptol.com [path]=>
/how-to/parsing-url.php [fragment] =>
content)

PHP code:

$url = "http://www.scriptol.com/how-to/parsing-url.php#content";
 $arr = parse_url($url);
 print_r($arr);

Answer 1, authority 100%

As an example, consider a link like this:

http://shurik:[email protected]:9191/documents.php?documentId=128&type=pdf#content

The parse_urlfunction returns an array of data that can contain the following keys:

  • scheme – well, it’s clear here, http or https or something else
  • host – this is also clear
  • port – the port to which we are connecting (in the url it is written after the host through a colon (in this case it is 9191))
  • user – usually not used, but in this case user will be shurik. Written at the beginning of the host
  • pass – password, written together with user in this case qwerty
  • path – path to the requested file. In this case: /documents.php (always starts with /)
  • query – query parameters, written in url after “?” in this case documentId=128&type=pdf
  • fragment is a pointer to an anchor, in this case content. Written after #

I hope this helped.

PS: >> Gives me only

well, that’s right, because you don’t have any other arguments in your url