How to parse an URL in php

How to parse an URL in php

In this blog i will discuss on URL parsing. `parse_url` function parse a URL and returns an associative array containing any of the various components of the URL that are present. The values of the array elements are not URL decoded. Use below code to parse a URL

$url = '';   //Any URL

Output:below code to parse an URL

Array ( [scheme] => https [host] => [path] => /abv [query] => slug=test )

Hi, I'm Saurav, the developer behind usingphp. Donate to help me keep usingphp free and maintained.

Please let me know what your thoughts or comments are on this article. If you have any suggestion or found any mistake in this article then please let us know.

Latest Comments

Add your comment