本文整理汇总了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());
}