本文整理汇总了PHP中Net_URL2::setQueryVariables方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_URL2::setQueryVariables方法的具体用法?PHP Net_URL2::setQueryVariables怎么用?PHP Net_URL2::setQueryVariables使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Net_URL2
的用法示例。
在下文中一共展示了Net_URL2::setQueryVariables方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: request
/**
* Http request
*
* @param string $method
* @param string $url
* @param array $submit
* @param string $formName
*
* @return HTTP_Request2_Response
*/
public function request($method, $url, array $submit = array(), $formName = 'form')
{
$this->request = new HTTP_Request2();
$url = new Net_URL2($url);
$this->request->setMethod($method);
if ($submit) {
$submit = array_merge(array('_token' => '0dc59902014b6', '_qf__' . $formName => ''), $submit);
}
if ($submit && $method === 'POST') {
$this->request->addPostParameter($submit);
}
if ($submit && $method === 'GET') {
$url->setQueryVariables($submit);
}
$this->request->setUrl($url);
$this->response = $this->request->send();
return $this;
}
示例2: validateReturnTo
/**
* Validates the openid.return_to parameter in the response.
*
* @return void
* @throws OpenID_Assertion_Exception on failure
*/
protected function validateReturnTo()
{
$returnTo = $this->message->get('openid.return_to');
OpenID::setLastEvent(__METHOD__, 'openid.return_to: ' . var_export($returnTo, true));
// Validate openid.return_to
if (!filter_var($returnTo, FILTER_VALIDATE_URL)) {
throw new OpenID_Assertion_Exception('openid.return_to parameter is invalid or missing');
}
$obj1 = new Net_URL2($returnTo);
$obj2 = $this->requestedURL;
$queryString1 = $obj1->getQueryVariables();
$queryString2 = $obj2->getQueryVariables();
$obj1->setQueryVariables(array());
$obj2->setQueryVariables(array());
if ($obj1->getURL() != $obj2->getURL()) {
throw new OpenID_Assertion_Exception('openid.return_to does not match the requested URL');
}
if (!count($queryString1) && !count($queryString2)) {
return;
}
foreach ($queryString1 as $param => $value) {
if (!isset($queryString2[$param]) || $queryString2[$param] != $value) {
throw new OpenID_Assertion_Exception('openid.return_to parameters do not match requested url');
}
}
}
示例3: testDontUseBrackets
public function testDontUseBrackets()
{
$url = new Net_URL2('http://example.org/', array(Net_URL2::OPTION_USE_BRACKETS => false));
$url->setQueryVariables(array('foo' => array('bar', 'foobar')));
$this->assertEquals('http://example.org/?foo=bar&foo=foobar', strval($url));
}