本文整理匯總了PHP中Uri::getAuthority方法的典型用法代碼示例。如果您正苦於以下問題:PHP Uri::getAuthority方法的具體用法?PHP Uri::getAuthority怎麽用?PHP Uri::getAuthority使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Uri
的用法示例。
在下文中一共展示了Uri::getAuthority方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: resolve
/**
* @param string $toResolve
* @return Uri
* @link http://tools.ietf.org/html/rfc3986#section-5.2.2
*/
public function resolve($toResolve)
{
$r = new Uri($toResolve);
if ($r->__toString() === '') {
return clone $this;
}
$base = $this;
$t = new \StdClass();
$t->scheme = '';
$t->authority = '';
$t->path = '';
$t->query = '';
$t->fragment = '';
if ('' !== $r->getScheme()) {
$t->scheme = $r->getScheme();
$t->authority = $r->getAuthority();
$t->path = $this->removeDotSegments($r->getPath());
$t->query = $r->getQuery();
} else {
if ('' !== $r->getAuthority()) {
$t->authority = $r->getAuthority();
$t->path = $this->removeDotSegments($r->getPath());
$t->query = $r->getQuery();
} else {
if ('' == $r->getPath()) {
$t->path = $base->getPath();
if ($r->getQuery()) {
$t->query = $r->getQuery();
} else {
$t->query = $base->getQuery();
}
} else {
if ($r->getPath() && substr($r->getPath(), 0, 1) == "/") {
$t->path = $this->removeDotSegments($r->getPath());
} else {
$t->path = $this->mergePaths($base->getPath(), $r->getPath());
}
$t->query = $r->getQuery();
}
$t->authority = $base->getAuthority();
}
$t->scheme = $base->getScheme();
}
$t->fragment = $r->getFragment();
$result = $this->reconstitute($t->scheme, $t->authority, $t->path, $t->query, $t->fragment);
return new Uri($result);
}
示例2: buildResolvedUriAgainst
private function buildResolvedUriAgainst(Uri $uri)
{
$scheme = $uri->getScheme();
$authority = $uri->getAuthority();
$path = $uri->getPath();
$query = $uri->getQuery();
if ($this->getAuthority()) {
$authority = $this->getAuthority();
$path = $this->getPath();
$query = $this->getQuery();
} elseif ($this->getPath()) {
$path = $this->buildResolvedPathAgainst($uri->getPath());
$query = $this->getQuery();
} elseif ($this->getQuery()) {
$query = $this->getQuery();
}
return $this->appendRelativeParts("{$scheme}://{$authority}{$path}", $query, $this->parts['fragment']);
}
示例3: testSetPort
public function testSetPort()
{
$uri = new Uri('http', 'www.yahoo.com:8080');
$this->assertEquals('www.yahoo.com:8080', $uri->getAuthority());
$this->assertEquals('www.yahoo.com', $uri->getHost());
$this->assertEquals(8080, $uri->getPort());
$this->assertEquals('http://www.yahoo.com:8080', $uri->toString());
}
示例4: testAuthority
public function testAuthority()
{
$uri1 = new Uri('http://user:password@example.com:81');
$this->assertEquals('user:password@example.com:81', $uri1->getAuthority());
}