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 = 'https://www.code-learn.com/abc/?slug=test';   //Any URL
print_r(parse_url($url));

Output:below code to parse an URL

Array ( [scheme] => https [host] => www.ecode-learn.com [path] => /abv [query] => slug=test )

Also Read: Insert Update Delete Select query in WordPress
Also Read: How to increase website speed

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 = 'https://www.code-learn.com/abc/?slug=test';   //Any URL
print_r(parse_url($url));

Output:below code to parse an URL

Array ( [scheme] => https [host] => www.ecode-learn.com [path] => /abv [query] => slug=test )

Also Read: Insert Update Delete Select query in WordPress
Also Read: How to increase website speed

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

Close