本文整理汇总了PHP中Net_URL2::setQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_URL2::setQuery方法的具体用法?PHP Net_URL2::setQuery怎么用?PHP Net_URL2::setQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Net_URL2
的用法示例。
在下文中一共展示了Net_URL2::setQuery方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetQuery
/**
* Tests setQuery().
*/
public function testSetQuery()
{
$url = new Net_URL2('http://www.example.com/');
$url->setQuery('flapdoodle&dilly%20all%20day');
$this->assertEquals($url->getURL(), 'http://www.example.com/?flapdoodle&dilly%20all%20day');
}
示例2: testGetQueryVariables
/**
* Test parsing of query variables
*
* @param string $query string
* @param mixed $expected null to test against parse_str() behavior
* @param array $options Net_URL2 options
*
* @dataProvider provideQueryStrings
* @covers Net_URL2::getQueryVariables
* @covers Net_URL2::_queryArrayByKey
* @covers Net_URL2::_queryArrayByBrackets
* @covers Net_URL2::_queryKeyBracketOffset
* @return void
*/
public function testGetQueryVariables($query, $expected = null, array $options = array())
{
$options = $this->_translateOptionData($options);
$url = new Net_URL2('', $options);
if ($expected === null) {
// parse_str() is in PHP before copy on write, therefore
// it uses pass-by-reference for $expected to return
// the array
parse_str($query, $expected);
}
// Xdebug: If breakpoints are ignored, see Xdebug Issue 0000924
$url->setQuery($query);
$actual = $url->getQueryVariables();
// Do two assertions, because the first one shows a more nice diff in case
// it fails and the second one is actually strict which is what has to be
// tested.
$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}