2 most common php url functions for daily use

Seldom every php developer need some php url functions to work with , usually while parsing a web portal or finding the links url functions come very handy.

Here are URL based functionalities a developer may need .

1) Get the url of the portal:-


echo $_SERVER('HTTP_HOST');

2) Parse the url for extracting all components:-


$url_demo = 'http://user:pass@host/path?arg=val';

print_r(parse_url($url_demo));

Hope these handy code snippets would help you to save time for URL formatting in PHP.

Leave a Reply