当前位置: 首页>>代码示例>>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;未经允许,请勿转载。