本文整理汇总了PHP中uri::replace方法的典型用法代码示例。如果您正苦于以下问题:PHP uri::replace方法的具体用法?PHP uri::replace怎么用?PHP uri::replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uri
的用法示例。
在下文中一共展示了uri::replace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Reset
/**
* @test
* @depends URI\ParseTest::Advanced_Parsing
* @depends Simple_Replace
* @depends Simple_Output
* @depends Aliases
* @depends URI\ErrorsTest::Parse_Errors
* @depends URI\ErrorsTest::Invalid_Section_Errors
*/
public function Reset()
{
$uri1 = new \uri('example.com/original/path');
// Check For Errors
$this->assertEmpty($uri1->error);
// Check Replace
$this->assertEquals('example.com/alternative/path', $uri1->replace('PATH', '/alternative/path'));
$uri1->reset();
$this->assertEquals('example.com/original/path', $uri1->str());
}
示例2: Invalid_Port
/**
* @test
* @depends URI\ParseTest::Advanced_Parsing
*/
public function Invalid_Port()
{
$uri1 = new \uri('https://user:pass@example.com:777/path/to/script.php?query=str#fragment');
// Invalid section to modify;
$this->assertEquals(FALSE, $uri1->replace('PORT', 'invalid'));
}
示例3: Modify_Fragment
/**
* @test
* @depends URI\GenerateTest::Reset
*/
public function Modify_Fragment()
{
// 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);
// Check Replace
$this->assertEquals('example.com#top', $uri1->replace('FRAGMENT', '#top'));
$this->assertEquals('example.com#header', $uri1->replace('FRAGMENT', 'header'));
$this->assertEquals('https://user:pass@example.com:777/path/to/script.php?query=str#footer', $uri2->replace('FRAGMENT', 'footer'));
// Check Prepend
$this->assertEquals('example.com#custom-header', $uri1->prepend('FRAGMENT', 'custom-'));
// Check Append
$this->assertEquals('https://user:pass@example.com:777/path/to/script.php?query=str#footer-end', $uri2->append('FRAGMENT', '-end'));
}