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


PHP Uri::composeComponents方法代碼示例

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


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

示例1: resolve

 /**
  * Converts the relative URI into a new URI that is resolved against the base URI.
  *
  * @param UriInterface $base Base URI
  * @param UriInterface $rel  Relative URI
  *
  * @return UriInterface
  * @link http://tools.ietf.org/html/rfc3986#section-5.2
  */
 public static function resolve(UriInterface $base, UriInterface $rel)
 {
     if ((string) $rel === '') {
         // we can simply return the same base URI instance for this same-document reference
         return $base;
     }
     if ($rel->getScheme() != '') {
         return $rel->withPath(self::removeDotSegments($rel->getPath()));
     }
     if ($rel->getAuthority() != '') {
         $targetAuthority = $rel->getAuthority();
         $targetPath = self::removeDotSegments($rel->getPath());
         $targetQuery = $rel->getQuery();
     } else {
         $targetAuthority = $base->getAuthority();
         if ($rel->getPath() === '') {
             $targetPath = $base->getPath();
             $targetQuery = $rel->getQuery() != '' ? $rel->getQuery() : $base->getQuery();
         } else {
             if ($rel->getPath()[0] === '/') {
                 $targetPath = $rel->getPath();
             } else {
                 if ($targetAuthority != '' && $base->getPath() === '') {
                     $targetPath = '/' . $rel->getPath();
                 } else {
                     $lastSlashPos = strrpos($base->getPath(), '/');
                     if ($lastSlashPos === false) {
                         $targetPath = $rel->getPath();
                     } else {
                         $targetPath = substr($base->getPath(), 0, $lastSlashPos + 1) . $rel->getPath();
                     }
                 }
             }
             $targetPath = self::removeDotSegments($targetPath);
             $targetQuery = $rel->getQuery();
         }
     }
     return new Uri(Uri::composeComponents($base->getScheme(), $targetAuthority, $targetPath, $targetQuery, $rel->getFragment()));
 }
開發者ID:nystudio107,項目名稱:instantanalytics,代碼行數:48,代碼來源:UriResolver.php


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