當前位置: 首頁>>代碼示例>>PHP>>正文


PHP uri::arr方法代碼示例

本文整理匯總了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']);
 }
開發者ID:projectcleverweb,項目名稱:php-uri,代碼行數:50,代碼來源:03_GenerateTest.php


注:本文中的uri::arr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。