本文整理汇总了PHP中uri::str方法的典型用法代码示例。如果您正苦于以下问题:PHP uri::str方法的具体用法?PHP uri::str怎么用?PHP uri::str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uri
的用法示例。
在下文中一共展示了uri::str方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Chain_Errors
/**
* @test
* @depends URI\GenerateTest::Reset
*/
public function Chain_Errors()
{
$uri1 = new \uri('example.com');
// Check For Errors
$this->assertEmpty($uri1->error);
// none of these do anything, but they should all still return the chain class
@$uri1->chain()->str()->to_string()->arr()->to_array()->path_info()->query_array()->query_exists()->query_get();
$this->assertSame(8, $uri1->chain()->error_count);
// invalid inputs (no notices)
$uri1->chain()->replace('SCHEME', '/invalid/')->prepend('SCHEME', '/invalid/')->append('SCHEME', '/invalid/')->query_rename('does_not_exist', 'nothing');
$this->assertSame(12, $uri1->chain()->error_count);
$this->assertEquals($uri1->input, $uri1->str());
}
示例2: 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);
}
示例3: Query_Rename
/**
* @test
* @depends URI\GenerateTest::Reset
*/
public function Query_Rename()
{
// 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');
$uri3 = new \uri('google.com?empty');
// Check For Errors
$this->assertEmpty($uri1->error);
$this->assertEmpty($uri2->error);
$this->assertFalse($uri1->query_rename('a', 'b'));
$this->assertEquals($uri1->input, $uri1->str());
$this->assertTrue($uri2->query_rename('query', 'test'));
$this->assertEquals('https://user:pass@example.com:777/path/to/script.php?test=str#fragment', $uri2->str());
$this->assertTrue($uri3->query_rename('empty', 'none'));
$this->assertEquals('google.com?none=', $uri3->str());
}
示例4: Modify_User
/**
* @test
* @depends URI\GenerateTest::Reset
*/
public function Modify_User()
{
// 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');
$uri3 = new \uri('user@gmail.com');
// user w/out pass
// Check For Errors
$this->assertEmpty($uri1->error);
$this->assertEmpty($uri2->error);
// Check Replace
$this->assertEquals('doe@example.com', $uri1->replace('USER', 'doe'));
$this->assertEquals('https://john:pass@example.com:777/path/to/script.php?query=str#fragment', $uri2->replace('USER', 'john'));
$uri3->user = 'jane';
$this->assertEquals('jane@gmail.com', $uri3->str());
// Check Prepend
$this->assertEquals('jdoe@example.com', $uri1->prepend('USER', 'j'));
// Check Append
$this->assertEquals('https://johnd:pass@example.com:777/path/to/script.php?query=str#fragment', $uri2->append('USER', 'd'));
// Check Alias
$this->assertEquals('dude@example.com', $uri1->replace('USERNAME', 'dude'));
}