本文整理匯總了PHP中URI::setURI方法的典型用法代碼示例。如果您正苦於以下問題:PHP URI::setURI方法的具體用法?PHP URI::setURI怎麽用?PHP URI::setURI使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類URI
的用法示例。
在下文中一共展示了URI::setURI方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: resolveRelativeURI
/**
* Combines one URI string with this one based on the rules set out in
* RFC 3986 Section 2
*
* @see http://tools.ietf.org/html/rfc3986#section-5.2
*
* @param string $uri
*/
public function resolveRelativeURI(string $uri)
{
/*
* NOTE: We don't use removeDotSegments in this
* algorithm since it's already done by this line!
*/
$relative = new URI();
$relative->setURI($uri);
if ($relative->getScheme() == $this->getScheme()) {
$relative->setScheme('');
}
$transformed = clone $relative;
// 5.2.2 Transform References
if (!empty($relative->getScheme())) {
$transformed->setScheme($relative->getScheme())->setAuthority($relative->getAuthority())->setPath($relative->getPath())->setQuery($relative->getQuery());
} else {
if (!empty($relative->getAuthority())) {
$transformed->setAuthority($relative->getAuthority())->setPath($relative->getPath())->setQuery($relative->getQuery());
} else {
if ($relative->getPath() == '') {
$transformed->setPath($this->getPath());
if (!is_null($relative->getQuery())) {
$transformed->setQuery($relative->getQuery());
} else {
$transformed->setQuery($this->getQuery());
}
} else {
if (substr($relative->getPath(), 0, 1) == '/') {
$transformed->setPath($relative->getPath());
} else {
$transformed->setPath($this->mergePaths($this, $relative));
}
$transformed->setQuery($relative->getQuery());
}
$transformed->setAuthority($this->getAuthority());
}
$transformed->setScheme($this->getScheme());
}
$transformed->setFragment($relative->getFragment());
return $transformed;
}