本文整理汇总了PHP中Zend\Uri\Uri::getQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Uri::getQuery方法的具体用法?PHP Uri::getQuery怎么用?PHP Uri::getQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Uri\Uri
的用法示例。
在下文中一共展示了Uri::getQuery方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
/**
* Send request to the remote server with streaming support.
*
* @param string $method
* @param \Zend\Uri\Uri $uri
* @param string $http_ver
* @param array $headers
* @param string $body
* @return string Request as string
*/
public function write($method, $uri, $http_ver = '1.1', $headers = array(),
$body = '')
{
// Make sure we're properly connected
if (! $this->socket) {
throw new Adapter\Exception(
'Trying to write but we are not connected');
}
$host = $uri->getHost();
$host = (strtolower($uri->getScheme()) == 'https' ? $this->config['ssltransport'] : 'tcp') . '://' . $host;
if ($this->connected_to[0] != $host || $this->connected_to[1] != $uri->getPort()) {
throw new Adapter\Exception(
'Trying to write but we are connected to the wrong host');
}
// Save request method for later
$this->method = $method;
// Build request headers
$path = $uri->getPath();
if ($uri->getQuery()) $path .= '?' . $uri->getQuery();
$request = "{$method} {$path} HTTP/{$http_ver}\r\n";
foreach ($headers as $k => $v) {
if (is_string($k)) $v = ucfirst($k) . ": $v";
$request .= "$v\r\n";
}
// Send the headers over
$request .= "\r\n";
if (! @fwrite($this->socket, $request)) {
throw new Adapter\Exception(
'Error writing request to server');
}
//read from $body, write to socket
$chunk = $body->read(self::CHUNK_SIZE);
while ($chunk !== FALSE) {
if (! @fwrite($this->socket, $chunk)) {
throw new Adapter\Exception(
'Error writing request to server');
}
$chunk = $body->read(self::CHUNK_SIZE);
}
$body->closeFileHandle();
return 'Large upload, request is not cached.';
}
示例2: write
/**
* Send request to the remote server
*
* @param string $method
* @param \Zend\Uri\Uri $uri
* @param string $http_ver
* @param array $headers
* @param string $body
* @return string Request as string
*/
public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '')
{
$host = $uri->getHost();
$host = strtolower($uri->getScheme()) == 'https' ? 'sslv2://' . $host : $host;
// Build request headers
$path = $uri->getPath();
if (empty($path)) {
$path = '/';
}
if ($uri->getQuery()) {
$path .= '?' . $uri->getQuery();
}
$request = "{$method} {$path} HTTP/{$http_ver}\r\n";
foreach ($headers as $k => $v) {
if (is_string($k)) {
$v = ucfirst($k) . ": {$v}";
}
$request .= "{$v}\r\n";
}
// Add the request body
$request .= "\r\n" . $body;
// Do nothing - just return the request as string
return $request;
}
示例3: write
/**
* Send request to the remote server
*
* @param string $method
* @param \Zend\Uri\Uri $uri
* @param string $httpVer
* @param array $headers
* @param string $body
* @throws AdapterException\RuntimeException
* @return string Request as string
*/
public function write($method, $uri, $httpVer = '1.1', $headers = array(), $body = '')
{
// Make sure we're properly connected
if (!$this->socket) {
throw new AdapterException\RuntimeException('Trying to write but we are not connected');
}
$host = $uri->getHost();
$host = (strtolower($uri->getScheme()) == 'https' ? $this->config['ssltransport'] : 'tcp') . '://' . $host;
if ($this->connectedTo[0] != $host || $this->connectedTo[1] != $uri->getPort()) {
throw new AdapterException\RuntimeException('Trying to write but we are connected to the wrong host');
}
// Save request method for later
$this->method = $method;
// Build request headers
$path = $uri->getPath();
if ($uri->getQuery()) {
$path .= '?' . $uri->getQuery();
}
$request = "{$method} {$path} HTTP/{$httpVer}\r\n";
foreach ($headers as $k => $v) {
if (is_string($k)) {
$v = ucfirst($k) . ": {$v}";
}
$request .= "{$v}\r\n";
}
if (is_resource($body)) {
$request .= "\r\n";
} else {
// Add the request body
$request .= "\r\n" . $body;
}
// Send the request
ErrorHandler::start();
$test = fwrite($this->socket, $request);
$error = ErrorHandler::stop();
if (false === $test) {
throw new AdapterException\RuntimeException('Error writing request to server', 0, $error);
}
if (is_resource($body)) {
if (stream_copy_to_stream($body, $this->socket) == 0) {
throw new AdapterException\RuntimeException('Error writing request to server');
}
}
return $request;
}
示例4: initiateHandshake
public function initiateHandshake(Uri $uri)
{
$challenge = self::randHybiKey();
$request = new Request();
$requestUri = $uri->getPath();
if ($uri->getQuery()) {
$requestUri .= "?" . $uri->getQuery();
}
$request->setUri($requestUri);
$request->getHeaders()->addHeaderLine("Connection", "Upgrade");
$request->getHeaders()->addHeaderLine("Host", $uri->getHost());
$request->getHeaders()->addHeaderLine("Sec-WebSocket-Key", $challenge);
$request->getHeaders()->addHeaderLine("Sec-WebSocket-Version", 13);
$request->getHeaders()->addHeaderLine("Upgrade", "websocket");
$this->setRequest($request);
$this->emit("request", array($request));
$this->_socket->write($request->toString());
return $request;
}
示例5: testGetQueryAsArrayReturnsCorrectArray
/**
* @group ZF-1480
*/
public function testGetQueryAsArrayReturnsCorrectArray()
{
$url = new Uri('http://example.com/foo/?test=a&var[]=1&var[]=2&some[thing]=3');
$this->assertEquals('test=a&var[]=1&var[]=2&some[thing]=3', $url->getQuery());
$exp = array('test' => 'a', 'var' => array(1, 2), 'some' => array('thing' => 3));
$this->assertEquals($exp, $url->getQueryAsArray());
}
示例6: parse
/**
* @inheritdoc
*/
public function parse($uri)
{
$uri = new Uri($uri);
return $this->formatResults(['scheme' => $uri->getScheme(), 'userinfo' => $uri->getUserInfo(), 'host' => $uri->getHost(), 'port' => $uri->getPort(), 'path' => $uri->getPath(), 'query' => $uri->getQuery(), 'fragment' => $uri->getFragment()]);
}
示例7: testParseTwice
public function testParseTwice()
{
$uri = new Uri();
$uri->parse('http://user@example.com:1/absolute/url?query#fragment');
$uri->parse('/relative/url');
$this->assertNull($uri->getScheme());
$this->assertNull($uri->getHost());
$this->assertNull($uri->getUserInfo());
$this->assertNull($uri->getPort());
$this->assertNull($uri->getQuery());
$this->assertNull($uri->getFragment());
}
示例8: write
/**
* Send request to the remote server
*
* @param string $method
* @param \Zend\Uri\Uri $uri
* @param string $httpVer
* @param array $headers
* @param string $body
* @return string Request as string
*/
public function write($method, $uri, $httpVer = '1.1', $headers = [], $body = '')
{
// Build request headers
$path = $uri->getPath();
if (empty($path)) {
$path = '/';
}
if ($uri->getQuery()) {
$path .= '?' . $uri->getQuery();
}
$request = "{$method} {$path} HTTP/{$httpVer}\r\n";
foreach ($headers as $k => $v) {
if (is_string($k)) {
$v = ucfirst($k) . ": {$v}";
}
$request .= "{$v}\r\n";
}
// Add the request body
$request .= "\r\n" . $body;
// Do nothing - just return the request as string
return $request;
}
示例9: getQuery
/**
* Get the URI query
*
* @return string|null
*/
public function getQuery()
{
return $this->uri->getQuery();
}