当前位置: 首页>>代码示例>>PHP>>正文


PHP Uri::getQuery方法代码示例

本文整理汇总了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.';
    }
开发者ID:niallmccrudden,项目名称:zf2,代码行数:58,代码来源:HttpAdapterStreamingSocket.php

示例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;
 }
开发者ID:nuklehed,项目名称:zf2,代码行数:34,代码来源:Test.php

示例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;
 }
开发者ID:leonardovn86,项目名称:zf2_basic2013,代码行数:56,代码来源:Socket.php

示例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;
 }
开发者ID:rb-cohen,项目名称:phpws,代码行数:19,代码来源:WebSocketTransportHybi.php

示例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());
 }
开发者ID:navassouza,项目名称:zf2,代码行数:10,代码来源:UriTest.php

示例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()]);
 }
开发者ID:nyamsprod,项目名称:uri-parser-benchmarks,代码行数:8,代码来源:Zend.php

示例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());
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:12,代码来源:UriTest.php

示例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;
 }
开发者ID:ameoba32,项目名称:zend-http,代码行数:32,代码来源:Test.php

示例9: getQuery

 /**
  * Get the URI query
  *
  * @return string|null
  */
 public function getQuery()
 {
     return $this->uri->getQuery();
 }
开发者ID:sunnyct,项目名称:silexcmf-core,代码行数:9,代码来源:Uri.php


注:本文中的Zend\Uri\Uri::getQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。