functions-online

parse_url

description

This function parses a URL and returns an associative array containing any of the various components of the URL that are present.

  • scheme - e.g. http
  • host
  • port
  • user
  • pass
  • path
  • query - after the question mark ?
  • fragment - after the hashmark #

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.

declaration of parse_url

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

test parse_url online







share parse_url

comments for parse_url

On 20. Mar 2015 03:14 anson wrote:

### url http://www.example.com/item.htm?spm=a217n.7287937.1998158644-1.5.uuAsMk&id=43122686836 ### The result of online test , which is right obviously array ( 'scheme' => 'http', 'host' => 'www.example.com', 'path' => '/item.htm', 'query' => 'spm=a217n.7287937.1998158644-1.5.uuAsMk&id=43122686836', ) ### And here is my result, u can see that the "query" loses the param "id" Array ( [scheme] => http [host] => www.example.com [path] => /item.htm [query] => spm=a217n.7287937.1998158644-1.5.uuAsMk ) ### environment Windows 7 PHP Version 5.3.28 ### Anyone encountered the same problem ?

+

Leave your comment