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


PHP uri::reset方法代碼示例

本文整理匯總了PHP中uri::reset方法的典型用法代碼示例。如果您正苦於以下問題:PHP uri::reset方法的具體用法?PHP uri::reset怎麽用?PHP uri::reset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在uri的用法示例。


在下文中一共展示了uri::reset方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Sudo_Magic_Constants

 /**
  * @test
  * @depends Reset
  */
 public function Sudo_Magic_Constants()
 {
     // Test both when there is and isn't pre-existing data
     $uri1 = new \uri('https://user:pass@example.com:777/path/to/script.php?query=str#fragment');
     $uri2 = new \uri('google.com');
     // Check For Errors
     $this->assertEmpty($uri1->error);
     $this->assertEmpty($uri2->error);
     // __get() (parser checks normal __get())
     $this->assertSame(NULL, @$uri1->does_not_exist);
     // __set()
     $uri2->scheme_name = 'http';
     $this->assertEquals('http://google.com', $uri2->str());
     $uri2->scheme_symbols = ':';
     $this->assertEquals('http:google.com', $uri2->str());
     $uri2->scheme = 'https://';
     $this->assertEquals('https://google.com', $uri2->str());
     $uri2->user = 'username';
     $this->assertEquals('https://username@google.com', $uri2->str());
     $uri2->pass = 'password';
     $this->assertEquals('https://username:password@google.com', $uri2->str());
     $uri2->host = 'facebook.com';
     $this->assertEquals('https://username:password@facebook.com', $uri2->str());
     $uri2->port = '8181';
     $this->assertEquals('https://username:password@facebook.com:8181', $uri2->str());
     $uri2->path = '/index.php';
     $this->assertEquals('https://username:password@facebook.com:8181/index.php', $uri2->str());
     $uri2->query = 'q=1';
     $this->assertEquals('https://username:password@facebook.com:8181/index.php?q=1', $uri2->str());
     $uri2->fragment = 'frag';
     $this->assertEquals('https://username:password@facebook.com:8181/index.php?q=1#frag', $uri2->str());
     $uri2->reset();
     @($uri1->does_not_exist = 'nothing');
     $this->assertSame(NULL, @$uri1->does_not_exist);
     // __isset()
     $this->assertTrue(isset($uri1->scheme_name));
     $this->assertFalse(isset($uri2->scheme_name));
     $this->assertTrue(isset($uri1->scheme_symbols));
     $this->assertFalse(isset($uri2->scheme_symbols));
     $this->assertTrue(isset($uri1->scheme));
     $this->assertFalse(isset($uri2->scheme));
     $this->assertTrue(isset($uri1->user));
     $this->assertFalse(isset($uri2->user));
     $this->assertTrue(isset($uri1->pass));
     $this->assertFalse(isset($uri2->pass));
     $this->assertTrue(isset($uri1->host));
     $this->assertTrue(isset($uri2->host));
     $this->assertTrue(isset($uri1->port));
     $this->assertFalse(isset($uri2->port));
     $this->assertTrue(isset($uri1->path));
     $this->assertFalse(isset($uri2->path));
     $this->assertTrue(isset($uri1->query));
     $this->assertFalse(isset($uri2->query));
     $this->assertTrue(isset($uri1->fragment));
     $this->assertFalse(isset($uri2->fragment));
     $this->assertFalse(isset($uri1->does_not_exist));
     // __unset()
     unset($uri1->scheme_name);
     $this->assertSame('', $uri1->scheme_name);
     $uri1->reset();
     unset($uri1->scheme_symbols);
     $this->assertSame('', $uri1->scheme_symbols);
     $uri1->reset();
     unset($uri1->scheme);
     $this->assertSame('', $uri1->scheme);
     $uri1->reset();
     unset($uri1->user);
     $this->assertSame('', $uri1->user);
     $uri1->reset();
     unset($uri1->pass);
     $this->assertSame('', $uri1->pass);
     $uri1->reset();
     error_reporting(0);
     unset($uri1->host);
     // Language Construct
     error_reporting(-1);
     $this->assertEquals('example.com', $uri1->host);
     unset($uri1->port);
     $this->assertSame('', $uri1->port);
     $uri1->reset();
     unset($uri1->path);
     $this->assertSame('', $uri1->path);
     $uri1->reset();
     unset($uri1->query);
     $this->assertSame('', $uri1->query);
     $uri1->reset();
     unset($uri1->fragment);
     $this->assertSame('', $uri1->fragment);
     $uri1->reset();
     error_reporting(0);
     unset($uri1->does_not_exist);
     // Language Construct
     error_reporting(-1);
     $this->assertSame(NULL, @$uri1->does_not_exist);
 }
開發者ID:projectcleverweb,項目名稱:php-uri,代碼行數:99,代碼來源:03_GenerateTest.php


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