本文整理匯總了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'));
}