本文整理汇总了PHP中uri::arr方法的典型用法代码示例。如果您正苦于以下问题:PHP uri::arr方法的具体用法?PHP uri::arr怎么用?PHP uri::arr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uri
的用法示例。
在下文中一共展示了uri::arr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: To_Array
/**
* @test
* @depends Reset
*/
public function To_Array()
{
// Test both when there is and isn't pre-existing data
$uri1 = new \uri('example.com');
$uri2 = new \uri('https://user:pass@example.com:777/path/to/script.php?query=str#fragment');
// Check For Errors
$this->assertEmpty($uri1->error);
$this->assertEmpty($uri2->error);
// Setup
$arr1 = $uri1->arr();
$arr2 = $uri2->arr();
// Check that all keys are set (even if empty)
$this->assertArrayHasKey('authority', $arr1);
$this->assertArrayHasKey('domain', $arr1);
$this->assertArrayHasKey('fqdn', $arr1);
$this->assertArrayHasKey('fragment', $arr1);
$this->assertArrayHasKey('host', $arr1);
$this->assertArrayHasKey('pass', $arr1);
$this->assertArrayHasKey('path', $arr1);
$this->assertArrayHasKey('port', $arr1);
$this->assertArrayHasKey('protocol', $arr1);
$this->assertArrayHasKey('query', $arr1);
$this->assertArrayHasKey('scheme', $arr1);
$this->assertArrayHasKey('scheme_name', $arr1);
$this->assertArrayHasKey('scheme_symbols', $arr1);
$this->assertArrayHasKey('user', $arr1);
$this->assertArrayHasKey('username', $arr1);
// Check Key Aliases
$this->assertSame($arr2['scheme'], $arr2['protocol']);
$this->assertSame($arr2['user'], $arr2['username']);
$this->assertSame($arr2['pass'], $arr2['password']);
$this->assertSame($arr2['host'], $arr2['domain']);
$this->assertSame($arr2['host'], $arr2['fqdn']);
// Check Values
$this->assertEquals('user:pass@example.com:777', $arr2['authority']);
$this->assertEquals('fragment', $arr2['fragment']);
$this->assertEquals('example.com', $arr2['host']);
$this->assertEquals('pass', $arr2['pass']);
$this->assertEquals('/path/to/script.php', $arr2['path']);
$this->assertEquals('777', $arr2['port']);
$this->assertEquals('query=str', $arr2['query']);
$this->assertEquals('https://', $arr2['scheme']);
$this->assertEquals('https', $arr2['scheme_name']);
$this->assertEquals('://', $arr2['scheme_symbols']);
$this->assertEquals('user', $arr2['user']);
}