Let\'s say I have a URL of the document linking to another document (which can be both absolute or relative) and I need to have this link in absolute.
I made the sim
$uri = "..";
$path = realpath($uri);
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
if($path){
$path = str_replace($root, "", $path);
$path = $_SERVER["SERVER_NAME"] . $path;
$protocol = "http";
if(isset($_SERVER["HTTPS"])){
$protocol .= "s";
}
$path = "{$protocol}://$path";
$path = str_replace("\\", "/", $path);
}
var_dump($path);
There is probably a better/quicker way, but I just knocked this up...