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


PHP URI::getQuery方法代码示例

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


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

示例1: resolveRelativeURI

 /**
  * Combines one URI string with this one based on the rules set out in
  * RFC 3986 Section 2
  *
  * @see http://tools.ietf.org/html/rfc3986#section-5.2
  *
  * @param string $uri
  */
 public function resolveRelativeURI(string $uri)
 {
     /*
      * NOTE: We don't use removeDotSegments in this
      * algorithm since it's already done by this line!
      */
     $relative = new URI();
     $relative->setURI($uri);
     if ($relative->getScheme() == $this->getScheme()) {
         $relative->setScheme('');
     }
     $transformed = clone $relative;
     // 5.2.2 Transform References
     if (!empty($relative->getScheme())) {
         $transformed->setScheme($relative->getScheme())->setAuthority($relative->getAuthority())->setPath($relative->getPath())->setQuery($relative->getQuery());
     } else {
         if (!empty($relative->getAuthority())) {
             $transformed->setAuthority($relative->getAuthority())->setPath($relative->getPath())->setQuery($relative->getQuery());
         } else {
             if ($relative->getPath() == '') {
                 $transformed->setPath($this->getPath());
                 if (!is_null($relative->getQuery())) {
                     $transformed->setQuery($relative->getQuery());
                 } else {
                     $transformed->setQuery($this->getQuery());
                 }
             } else {
                 if (substr($relative->getPath(), 0, 1) == '/') {
                     $transformed->setPath($relative->getPath());
                 } else {
                     $transformed->setPath($this->mergePaths($this, $relative));
                 }
                 $transformed->setQuery($relative->getQuery());
             }
             $transformed->setAuthority($this->getAuthority());
         }
         $transformed->setScheme($this->getScheme());
     }
     $transformed->setFragment($relative->getFragment());
     return $transformed;
 }
开发者ID:rebekz,项目名称:php-framework-benchmark,代码行数:49,代码来源:URI.php

示例2: testSetQueryArraySetsValue

 public function testSetQueryArraySetsValue()
 {
     $url = 'http://example.com/path';
     $uri = new URI($url);
     $expected = 'http://example.com/path?key=value';
     $uri->setQueryArray(['key' => 'value']);
     $this->assertEquals('key=value', $uri->getQuery());
     $this->assertEquals($expected, (string) $uri);
 }
开发者ID:titounnes,项目名称:CodeIgniter4,代码行数:9,代码来源:URITest.php


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