I want to get host name from and inner URL. how to take that.
eg :- this is the inner url format .. http://hostname.com/folder/folder2/test.php?id=243432432424
http://hostname.com/folder/folder2/test.php?id=243432432424
A concise way would be:
$url = 'http://hostname.com/folder/folder2/test.php?id=243432432424243'; echo parse_url($url, PHP_URL_SCHEME).'://'.parse_url($url, PHP_URL_HOST);
This produces:
http://hostname.com