本文整理汇总了PHP中URI::setScheme方法的典型用法代码示例。如果您正苦于以下问题:PHP URI::setScheme方法的具体用法?PHP URI::setScheme怎么用?PHP URI::setScheme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URI
的用法示例。
在下文中一共展示了URI::setScheme方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetSchemeSetsValue
public function testSetSchemeSetsValue()
{
$url = 'http://example.com/path';
$uri = new URI($url);
$expected = 'https://example.com/path';
$uri->setScheme('https');
$this->assertEquals('https', $uri->getScheme());
$this->assertEquals($expected, (string) $uri);
}
示例2: 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;
}