samedi
Существует ли такая функция, которая получает адрес текущей страницы и ссылку с относительным путём и возвращает абсолютный путь ссылки?
Скажем так
$url = 'https://www.master-x.com/forum/posting.htm';
$link = '../index.htm';
$abs = func ($url, $link);
где $abs = 'https://www.master-x.com/index.htm'
EllGree
У меня как раз был открыт класс браузера, где есть соотв. метод:
Код:
function adjust($uri) {
if(!eregi('^http',$uri)) { // path need to adjust
if(eregi('^[a-z]+:',$uri)) { // mailto: ftp:// etc.
return $uri;
}
if(eregi('^/',$uri)) { // Absolute path
return $this->Parsed['scheme'].'://'.$this->Parsed['host'].$uri;
}
$path = explode('/',$this->Parsed['path']);
unset($path[count($path)-1]);
$path=implode('/',$path);
while(eregi('^\.\./',$uri)) {
$uri = substr($uri,3);
$path = explode('/',$path);
unset($path[count($path)-1]);
$path=implode('/',$path);
}
return $this->Parsed['scheme'].'://'.$this->Parsed['host'].$path.'/'.$uri;
}
return $uri;
}
// ну а
// $this->Parsed = parse_url($URL);
GTAlex
EllGree писал:
У меня как раз был открыт класс браузера, где есть соотв. метод:
думаю нагловато, но всё таки -
как на счёт весь класс дать посмотреть
?