本文整理匯總了PHP中Uri::withScheme方法的典型用法代碼示例。如果您正苦於以下問題:PHP Uri::withScheme方法的具體用法?PHP Uri::withScheme怎麽用?PHP Uri::withScheme使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Uri
的用法示例。
在下文中一共展示了Uri::withScheme方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testGettersAndSetters
public function testGettersAndSetters()
{
$uri1 = new Uri('');
$uri2 = $uri1->withScheme('HTTP')->withUserInfo('foo', 'bar')->withHost('EXAMPLE.com')->withPort(81)->withPath('/FOO/bar')->withQuery('a=2&b=3')->withFragment('foobar');
$this->assertEquals('http', $uri2->getScheme());
$this->assertEquals('foo:bar', $uri2->getUserInfo());
$this->assertEquals('example.com', $uri2->getHost());
$this->assertEquals(81, $uri2->getPort());
$this->assertEquals('/foo/bar', $uri2->getPath());
$this->assertEquals('a=2&b=3', $uri2->getQuery());
$this->assertEquals('foobar', $uri2->getFragment());
}
示例2: testWithScheme
public function testWithScheme()
{
$uri = new Uri('http://www.yahoo.com');
$this->assertEquals('https://www.yahoo.com', $uri->withScheme('https')->toString());
$uri = new Uri('http://user:password@example.com:8042/over/there?name=ferret&foo=bar#nose');
$this->assertEquals('https://user:password@example.com:8042/over/there?name=ferret&foo=bar#nose', $uri->withScheme('https')->toString());
}