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


PHP Uri::isAbsolute方法代碼示例

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


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

示例1: getRedirect

 public function getRedirect($urlString, $stayLocal = true, $preserveHttps = true)
 {
     /**
      * Check that the URL has the correct format expected of a valid HTTP
      * or HTTPS URL. If so, normalize the URL.
      */
     $valid = false;
     $url = new Uri();
     try {
         $url->parse($urlString);
         if ($url->isValid() && $url->isAbsolute()) {
             $url->normalize();
             $valid = true;
         }
     } catch (\Exception $e) {
     }
     if (false === $valid) {
         throw new Exception\InvalidArgumentException("Given value was not a valid absolute HTTP(S) URL: " . $url);
     }
     /**
      * Make sure we don't redirect from HTTPS to HTTP unless flagged by
      * the user. Using a Strict-Transport-Security header helps too!
      */
     if (true === (bool) $preserveHttps && HttpsDetector::isHttpsRequest()) {
         if (!$this->isHttps($url)) {
             throw new Exception\InvalidArgumentException("Given value was not a HTTPS URL as expected: " . $url);
         }
     }
     /**
      * Check if the URL meets the local host restriction unless disabled
      */
     if (true === $stayLocal && !$this->isLocal($url)) {
         throw new Exception\InvalidArgumentException("Given value was not a local HTTP(S) URL: " . $url);
     }
     /**
      * Check if the URL host exists on a whitelist of allowed hosts
      */
     $whitelist = $this->getWhitelist();
     if (!empty($whitelist) && !$this->isWhitelisted($url)) {
         throw new Exception\InvalidArgumentException("Given value was not a whitelisted URL as expected: " . $url);
     }
     /**
      * Get URL string after URL encoding checks and return a Location header
      * object.
      */
     $header = new Header\Location(array('url' => $url->toString(), 'status_code' => 302));
     return $header;
 }
開發者ID:emma5021,項目名稱:toba,代碼行數:48,代碼來源:Redirector.php

示例2: isAbsoluteUrl

 protected function isAbsoluteUrl($link)
 {
     $uri = new Uri($link);
     return $uri->isAbsolute();
 }
開發者ID:Andyyang1981,項目名稱:pi,代碼行數:5,代碼來源:CarouselController.php

示例3: isAbsolute

 /**
  * Check if the URI is an absolute or relative URI
  *
  * @return bool
  */
 public function isAbsolute()
 {
     return $this->uri->isAbsolute();
 }
開發者ID:sunnyct,項目名稱:silexcmf-core,代碼行數:9,代碼來源:Uri.php


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