本文整理汇总了PHP中Net_URL2::getQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_URL2::getQuery方法的具体用法?PHP Net_URL2::getQuery怎么用?PHP Net_URL2::getQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Net_URL2
的用法示例。
在下文中一共展示了Net_URL2::getQuery方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getVerifyResultsAndMessage
/**
* Creates an assertion object and tries to verify its validity.
*
* @return array of the OpenID_Assertion_Result and OpenID_Message objects
*/
public function getVerifyResultsAndMessage()
{
$rp = $this->getORPInstance();
$url = 'http';
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
$url .= 's';
}
$url .= '://' . $_SERVER['SERVER_NAME'];
if ($_SERVER['SERVER_PORT'] != '80') {
$url .= ':' . $_SERVER['SERVER_PORT'];
}
$url .= $_SERVER['PHP_SELF'];
// Get the message contents
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Can't use $_POST, it fucks with the keys (. -> _)
$queryString = $this->getPHPInput();
} else {
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
$netURL = new Net_URL2($url . '?' . $_SERVER['QUERY_STRING']);
$queryString = $netURL->getQuery();
if ($queryString === false) {
throw new OpenID_Exception('Invalid request');
}
} else {
throw new OpenID_Exception('Unknown HTTP method');
}
}
$requestedURL = $url . '?' . $queryString;
$message = new OpenID_Message($queryString, OpenID_Message::FORMAT_HTTP);
$result = $rp->verify(new Net_URL2($requestedURL), $message);
return array('result' => $result, 'message' => $message);
}
示例2: getQuery
/**
* Returns the query portion of the url.
*
* @return string
*/
public function getQuery()
{
return $this->_url->getQuery();
}
示例3: __get
/**
* Property getter interceptor to handle "uri" and "host" special cases.
*
* @param string $property The property to retrieve
*
* @return mixed
*/
public function __get($property)
{
switch ($property) {
case 'uri':
if ($this->_uri !== null) {
return $this->_uri->getURL();
}
return null;
case 'proxy':
return $this->_proxy;
case 'path':
if ($this->_uri === null) {
return null;
}
if ($this->httpVersion == self::HTTP_VERSION_1_0 || $this->proxy) {
// if http 1.0 or proxy given, the request uri must be absolute
return $this->_uri->getURL();
}
if (($path = $this->_uri->getPath()) === false) {
$path = '/';
}
if (($query = $this->_uri->getQuery()) !== false) {
$path .= '?' . $query;
}
if (($fragment = $this->_uri->getFragment()) !== false) {
$path .= '#' . $fragment;
}
return $path;
case 'host':
if (isset($this->headers['host'])) {
return trim($this->headers['host']);
}
if ($this->_proxy !== null) {
return $this->_proxy;
}
if ($this->_uri !== null) {
$host = $this->_uri->getHost();
if (($port = $this->_uri->getPort()) !== false) {
$host .= ':' . $port;
}
}
return $host;
case 'port':
$port = $this->_uri->getPort();
if (!is_numeric($port)) {
return $this->isSecure() ? 443 : 80;
}
return $port;
case 'connection':
if ($this->_connection === null) {
include_once 'HTTP/Connection.php';
$this->_connection = HTTP_Connection::factory('Socket');
}
return $this->_connection;
default:
return parent::__get($property);
}
}
示例4: testQueryVariables
/**
* This is some example code from a bugreport. Trying to proof that
* the parsing works indeed.
*
* @return void
* @link http://pear.php.net/bugs/bug.php?id=17036
*/
public function testQueryVariables()
{
$queryString = 'start=10&test[0][first][1.1][20]=coucou';
$url = new Net_URL2('?' . $queryString);
$vars = array();
parse_str($url->getQuery(), $vars);
$this->assertEquals('10', $vars['start']);
$this->assertEquals('coucou', $vars['test'][0]['first']['1.1'][20]);
}
示例5: test19684
/**
* This is a regression test to test that recovering from
* a wrongly encoded URL is possible.
*
* It was requested as Request #19684 on 2011-12-31 02:07 UTC
* that redirects containing spaces should work.
*
* @return void
*/
public function test19684()
{
// Location: URL obtained Thu, 25 Apr 2013 20:51:31 GMT
$urlWithSpace = 'http://www.sigmaaldrich.com/catalog/search?interface=CAS N' . 'o.&term=108-88-3&lang=en®ion=US&mode=match+partialmax&N=0+2200030' . '48+219853269+219853286';
$urlCorrect = 'http://www.sigmaaldrich.com/catalog/search?interface=CAS%20N' . 'o.&term=108-88-3&lang=en®ion=US&mode=match+partialmax&N=0+2200030' . '48+219853269+219853286';
$url = new Net_URL2($urlWithSpace);
$this->assertTrue($url->isAbsolute());
$urlPart = parse_url($urlCorrect, PHP_URL_PATH);
$this->assertSame($urlPart, $url->getPath());
$urlPart = parse_url($urlCorrect, PHP_URL_QUERY);
$this->assertSame($urlPart, $url->getQuery());
$this->assertSame($urlCorrect, (string) $url);
$input = 'http://example.com/get + + to my nose/';
$expected = 'http://example.com/get%20+%20+%20to%20my%20nose/';
$actual = new Net_URL2($input);
$this->assertEquals($expected, $actual);
$actual->normalize();
}