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


PHP Http::getQuery方法代码示例

本文整理汇总了PHP中Zend\Uri\Http::getQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Http::getQuery方法的具体用法?PHP Http::getQuery怎么用?PHP Http::getQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Uri\Http的用法示例。


在下文中一共展示了Http::getQuery方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testAssembling

 /**
  * @param        Query $route
  * @param        string   $path
  * @param        integer  $offset
  * @param        array    $params
  * @param        boolean  $skipAssembling
  */
 public function testAssembling(Query $route, $path, $offset, array $params = null, $skipAssembling = false)
 {
     if ($params === null || $skipAssembling) {
         // Data which will not match are not tested for assembling.
         return;
     }
     $uri = new Http();
     $result = $route->assemble($params, array('uri' => $uri));
     if ($offset !== null) {
         $this->assertEquals($offset, strpos($path, $uri->getQuery(), $offset));
     } else {
         $this->assertEquals($path, $uri->getQuery());
     }
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:21,代码来源:QueryTest.php

示例2: doRequest

 /**
  * @param Request $request
  *
  * @return Response
  * @throws \Exception
  */
 public function doRequest($request)
 {
     $zendRequest = $this->application->getRequest();
     $zendResponse = $this->application->getResponse();
     $zendResponse->setStatusCode(200);
     $uri = new HttpUri($request->getUri());
     $queryString = $uri->getQuery();
     $method = strtoupper($request->getMethod());
     $zendRequest->setCookies(new Parameters($request->getCookies()));
     if ($queryString) {
         parse_str($queryString, $query);
         $zendRequest->setQuery(new Parameters($query));
     }
     if ($request->getContent() !== null) {
         $zendRequest->setContent($request->getContent());
     } elseif ($method != HttpRequest::METHOD_GET) {
         $post = $request->getParameters();
         $zendRequest->setPost(new Parameters($post));
     }
     $zendRequest->setMethod($method);
     $zendRequest->setUri($uri);
     $zendRequest->setRequestUri(str_replace('http://localhost', '', $request->getUri()));
     $zendRequest->setHeaders($this->extractHeaders($request));
     $this->application->run();
     $this->zendRequest = $zendRequest;
     $exception = $this->application->getMvcEvent()->getParam('exception');
     if ($exception instanceof \Exception) {
         throw $exception;
     }
     $response = new Response($zendResponse->getBody(), $zendResponse->getStatusCode(), $zendResponse->getHeaders()->toArray());
     return $response;
 }
开发者ID:namnv609,项目名称:Codeception,代码行数:38,代码来源:ZF2.php

示例3: doRequest

 /**
  * @param Request $request
  *
  * @return Response
  * @throws \Exception
  */
 public function doRequest($request)
 {
     $zendRequest = $this->application->getRequest();
     $zendResponse = $this->application->getResponse();
     $uri = new HttpUri($request->getUri());
     $queryString = $uri->getQuery();
     $method = $request->getMethod();
     if ($queryString) {
         parse_str($queryString, $query);
     }
     if ($method == HttpRequest::METHOD_POST) {
         $post = $request->getParameters();
         $zendRequest->setPost(new Parameters($post));
     } elseif ($method == HttpRequest::METHOD_GET) {
         $query = $request->getParameters();
         $zendRequest->setQuery(new Parameters($query));
     } elseif ($method == HttpRequest::METHOD_PUT) {
         $zendRequest->setContent($request->getContent());
     }
     $zendRequest->setMethod($method);
     $zendRequest->setUri($uri);
     $this->application->run();
     $this->zendRequest = $zendRequest;
     $exception = $this->application->getMvcEvent()->getParam('exception');
     if ($exception instanceof \Exception) {
         throw $exception;
     }
     $response = new Response($zendResponse->getBody(), $zendResponse->getStatusCode(), $zendResponse->getHeaders()->toArray());
     return $response;
 }
开发者ID:NaszvadiG,项目名称:ImageCMS,代码行数:36,代码来源:ZF2.php

示例4: write

 /**
  * Send request to the remote server with streaming support.
  *
  * @param string        $method
  * @param \Zend\Uri\Http $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:rmarshall-quibids,项目名称:zf2,代码行数:51,代码来源:HttpAdapterStreamingSocket.php

示例5: doRequest

 /**
  * @param Request $request
  *
  * @return Response
  * @throws \Exception
  */
 public function doRequest($request)
 {
     $this->createApplication();
     $zendRequest = $this->application->getRequest();
     $uri = new HttpUri($request->getUri());
     $queryString = $uri->getQuery();
     $method = strtoupper($request->getMethod());
     $zendRequest->setCookies(new Parameters($request->getCookies()));
     $query = [];
     $post = [];
     $content = $request->getContent();
     if ($queryString) {
         parse_str($queryString, $query);
     }
     if ($method !== HttpRequest::METHOD_GET) {
         $post = $request->getParameters();
     }
     $zendRequest->setQuery(new Parameters($query));
     $zendRequest->setPost(new Parameters($post));
     $zendRequest->setFiles(new Parameters($request->getFiles()));
     $zendRequest->setContent($content);
     $zendRequest->setMethod($method);
     $zendRequest->setUri($uri);
     $requestUri = $uri->getPath();
     if (!empty($queryString)) {
         $requestUri .= '?' . $queryString;
     }
     $zendRequest->setRequestUri($requestUri);
     $zendRequest->setHeaders($this->extractHeaders($request));
     $this->application->run();
     // get the response *after* the application has run, because other ZF
     //     libraries like API Agility may *replace* the application's response
     //
     $zendResponse = $this->application->getResponse();
     $this->zendRequest = $zendRequest;
     $exception = $this->application->getMvcEvent()->getParam('exception');
     if ($exception instanceof \Exception) {
         throw $exception;
     }
     $response = new Response($zendResponse->getBody(), $zendResponse->getStatusCode(), $zendResponse->getHeaders()->toArray());
     return $response;
 }
开发者ID:solutionDrive,项目名称:Codeception,代码行数:48,代码来源:ZF2.php

示例6: doRequest

 /**
  * @param Request $request
  *
  * @return Response
  * @throws \Exception
  */
 public function doRequest($request)
 {
     $zendRequest = $this->application->getRequest();
     $zendResponse = $this->application->getResponse();
     $zendHeaders = $zendRequest->getHeaders();
     if (!$zendHeaders->has('Content-Type')) {
         $server = $request->getServer();
         if (isset($server['CONTENT_TYPE'])) {
             $zendHeaders->addHeaderLine('Content-Type', $server['CONTENT_TYPE']);
         }
     }
     $zendResponse->setStatusCode(200);
     $uri = new HttpUri($request->getUri());
     $queryString = $uri->getQuery();
     $method = strtoupper($request->getMethod());
     $zendRequest->setCookies(new Parameters($request->getCookies()));
     if ($queryString) {
         parse_str($queryString, $query);
         $zendRequest->setQuery(new Parameters($query));
     }
     if ($method == HttpRequest::METHOD_POST) {
         $post = $request->getParameters();
         $zendRequest->setPost(new Parameters($post));
     } elseif ($method == HttpRequest::METHOD_PUT) {
         $zendRequest->setContent($request->getContent());
     }
     $zendRequest->setMethod($method);
     $zendRequest->setUri($uri);
     $this->application->run();
     $this->zendRequest = $zendRequest;
     $exception = $this->application->getMvcEvent()->getParam('exception');
     if ($exception instanceof \Exception) {
         throw $exception;
     }
     $response = new Response($zendResponse->getBody(), $zendResponse->getStatusCode(), $zendResponse->getHeaders()->toArray());
     return $response;
 }
开发者ID:alexanderkuz,项目名称:test-yii2,代码行数:43,代码来源:ZF2.php

示例7: url

 /**
  * Set the request URL
  *
  * @param  string                     $url
  * @param  string|null                $method
  * @param  array|null                 $params
  * @return AbstractControllerTestCase
  */
 public function url($url, $method = HttpRequest::METHOD_GET, $params = [])
 {
     $request = $this->getRequest();
     if ($this->useConsoleRequest) {
         preg_match_all('/(--\\S+[= ]"[^\\s"]*\\s*[^\\s"]*")|(--\\S+=\\S+|--\\S+\\s\\S+|\\S+)/', $url, $matches);
         $params = str_replace([' "', '"'], ['=', ''], $matches[0]);
         $request->params()->exchangeArray($params);
         return $this;
     }
     $query = $request->getQuery()->toArray();
     $post = $request->getPost()->toArray();
     $uri = new HttpUri($url);
     $queryString = $uri->getQuery();
     if ($queryString) {
         parse_str($queryString, $query);
     }
     if ($method == HttpRequest::METHOD_POST) {
         if (count($params) != 0) {
             $post = $params;
         }
     } elseif ($method == HttpRequest::METHOD_GET) {
         $query = array_merge($query, $params);
     } elseif ($method == HttpRequest::METHOD_PUT || $method == HttpRequest::METHOD_PATCH) {
         if (count($params) != 0) {
             $content = http_build_query($params);
             $request->setContent($content);
         }
     } elseif ($params) {
         trigger_error('Additional params is only supported by GET, POST, PUT and PATCH HTTP method', E_USER_NOTICE);
     }
     $request->setMethod($method);
     $request->setQuery(new Parameters($query));
     $request->setPost(new Parameters($post));
     $request->setUri($uri);
     $request->setRequestUri($uri->getPath());
     return $this;
 }
开发者ID:CHRISTOPHERVANDOMME,项目名称:zf2complet,代码行数:45,代码来源:AbstractControllerTestCase.php

示例8: url

 /**
  * Set the request URL
  *
  * @param  string $url
  * @param  string|null $method
  * @param  array|null $params
  * @return AbstractControllerTestCase
  */
 public function url($url, $method = HttpRequest::METHOD_GET, $params = array())
 {
     $request = $this->getRequest();
     if ($this->useConsoleRequest) {
         preg_match_all('/(--\\S+[= ]"\\S*\\s*\\S*")|(--\\S+=\\S+|--\\S+\\s\\S+|\\S+)/', $url, $matches);
         $params = str_replace(array(' "', '"'), array('=', ''), $matches[0]);
         $request->params()->exchangeArray($params);
         return $this;
     }
     $query = $request->getQuery()->toArray();
     $post = $request->getPost()->toArray();
     $uri = new HttpUri($url);
     $queryString = $uri->getQuery();
     if ($queryString) {
         parse_str($queryString, $query);
     }
     if ($method == HttpRequest::METHOD_POST) {
         if (count($params) != 0) {
             $post = $params;
         }
     } elseif ($method == HttpRequest::METHOD_GET) {
         $query = array_merge($query, $params);
     } elseif ($method == HttpRequest::METHOD_PUT) {
         if (count($params) != 0) {
             array_walk($params, function (&$item, $key) {
                 $item = $key . '=' . $item;
             });
             $content = implode('&', $params);
             $request->setContent($content);
         }
     } elseif ($params) {
         trigger_error('Additional params is only supported by GET, POST and PUT HTTP method', E_USER_NOTICE);
     }
     $request->setMethod($method);
     $request->setQuery(new Parameters($query));
     $request->setPost(new Parameters($post));
     $request->setUri($uri);
     $request->setRequestUri($uri->getPath());
     return $this;
 }
开发者ID:killturinG,项目名称:zf2,代码行数:48,代码来源:AbstractControllerTestCase.php

示例9: url

 /**
  * Set the request URL
  *
  * @param  string $url
  * @return AbstractControllerTestCase
  */
 public function url($url, $method = HttpRequest::METHOD_GET, $params = array())
 {
     $request = $this->getRequest();
     if ($this->useConsoleRequest) {
         $params = preg_split('#\\s+#', $url);
         $request->params()->exchangeArray($params);
         return $this;
     }
     $query = $request->getQuery()->toArray();
     $post = $request->getPost()->toArray();
     $uri = new HttpUri($url);
     $queryString = $uri->getQuery();
     if ($queryString) {
         parse_str($queryString, $query);
     }
     if ($method == HttpRequest::METHOD_POST) {
         $post = $params;
     }
     if ($method == HttpRequest::METHOD_GET) {
         $query = array_merge($query, $params);
     }
     $request->setMethod($method);
     $request->setQuery(new Parameters($query));
     $request->setPost(new Parameters($post));
     $request->setUri($uri);
     return $this;
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:33,代码来源:AbstractControllerTestCase.php


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