當前位置: 首頁>>代碼示例>>PHP>>正文


PHP URI::setScheme方法代碼示例

本文整理匯總了PHP中URI::setScheme方法的典型用法代碼示例。如果您正苦於以下問題:PHP URI::setScheme方法的具體用法?PHP URI::setScheme怎麽用?PHP URI::setScheme使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在URI的用法示例。


在下文中一共展示了URI::setScheme方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testSetSchemeSetsValue

 public function testSetSchemeSetsValue()
 {
     $url = 'http://example.com/path';
     $uri = new URI($url);
     $expected = 'https://example.com/path';
     $uri->setScheme('https');
     $this->assertEquals('https', $uri->getScheme());
     $this->assertEquals($expected, (string) $uri);
 }
開發者ID:titounnes,項目名稱:CodeIgniter4,代碼行數:9,代碼來源:URITest.php

示例2: 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


注:本文中的URI::setScheme方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。