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


PHP Uri::isValid方法代码示例

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


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

示例1: isValid

 /**
  * Check if the URI is valid
  *
  * Note that a relative URI may still be valid
  *
  * @access public
  * @return bool
  */
 public function isValid()
 {
     if ($this->isValidEmptyUri() === true) {
         $isValid = true;
     } else {
         $isValid = parent::isValid();
     }
     return $isValid;
 }
开发者ID:camelcasetechsd,项目名称:certigate,代码行数:17,代码来源:Uri.php

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

示例3: isDocumentHref

 public static function isDocumentHref($href)
 {
     if (empty($href) || stripos($href, 'mail') !== false || stripos($href, '.pdf') !== false || stripos($href, '.ppt') !== false || substr($href, 0, 10) === 'javascript' || substr($href, 0, 1) === '#') {
         return false;
     }
     foreach (['%20', '='] as $c) {
         if (stripos($href, $c . 'http://') !== false) {
             return false;
         }
     }
     $zendUri = new Uri($href);
     if ($zendUri->isValid()) {
         return true;
     }
     return false;
 }
开发者ID:eduardohayashi,项目名称:camel-webspider,代码行数:16,代码来源:SpiderAsserts.php

示例4: testInvalidUriIsInvalid

 /**
  * Test that invalid URIs fail validation
  *
  * @param \Zend\Uri\Uri $uri
  * @dataProvider invalidUriObjectProvider
  */
 public function testInvalidUriIsInvalid(Uri $uri)
 {
     $this->assertFalse($uri->isValid());
 }
开发者ID:navassouza,项目名称:zf2,代码行数:10,代码来源:UriTest.php

示例5: isValid

 /**
  * Check if the URI is valid
  *
  * @return bool
  */
 public function isValid()
 {
     return $this->uri->isValid();
 }
开发者ID:sunnyct,项目名称:silexcmf-core,代码行数:9,代码来源:Uri.php


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