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=243432432424243
How to take the http://hostname.com
from the above URL using php?
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=243432432424243
How to take the http://hostname.com
from the above URL using php?
A concise way would be:
This produces:
Use
parse_url
.You want the
'scheme'
and'host'
elements of the output array (and maybe'port'
,'user'
and'password'
as well - you can usehttp_build_url
to stick these bits together if you want).