PHP convert external relative path to absolute path
Posted
by CMC
on Stack Overflow
See other posts from Stack Overflow
or by CMC
Published on 2010-05-20T01:39:45Z
Indexed on
2010/05/20
1:50 UTC
Read the original article
Hit count: 399
Hello, I am trying to figure out how to convert an "external relative path" to an absolute one: I'd really like a function that will do the following:
$path = "/search?q=query";
$host = "http://google.com";
$abspath = reltoabs($host, $path);
And have $abspath equal to "http://google.com/search?q=query" The problem is that it is not guaranteed to be in that format, and it could already be absolute, or be pointing to a different host entirely, and I'm not quite sure how to approach this. Thanks.
© Stack Overflow or respective owner