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


PHP CUrl::leaveTdNew方法代码示例

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


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

示例1: __construct

 /**
  * Creates a URL path from a path string or as empty.
  *
  * If a source path string is provided, it should start with "/". Just like in any valid URL, the path string is
  * not expected to contain characters that cannot be represented literally and percent-encoding is expected to be
  * used for any such characters. No trailing "/" are stripped off the path string, so if the path is e.g.
  * "/comp0/comp1/", it produces an empty string as the last component.
  *
  * @param  string $path **OPTIONAL. Default is** *create an empty URL path*. A string with the source path.
  */
 public function __construct($path = null)
 {
     assert('!isset($path) || is_cstring($path)', vs(isset($this), get_defined_vars()));
     assert('!isset($path) || CString::startsWith($path, "/")', vs(isset($this), get_defined_vars()));
     if (isset($path)) {
         $path = CString::stripStart($path, "/");
         $this->m_components = CString::split($path, "/");
         $len = CArray::length($this->m_components);
         for ($i = 0; $i < $len; $i++) {
             $this->m_components[$i] = CUrl::leaveTdNew($this->m_components[$i]);
         }
     } else {
         $this->m_components = CArray::make();
     }
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:25,代码来源:CUrlPath.php

示例2: __construct

 /**
  * Creates a parsed URL from a URL string.
  *
  * The URL string is expected to be by all means valid, with characters being percent-encoded where it is required
  * by the URL standard and without any leading or trailing whitespace. It is only when the URL string does not
  * indicate any protocol that the URL may still be considered valid and the default protocol is assigned to the
  * URL, which is "http".
  *
  * @param  string $url The URL string.
  */
 public function __construct($url)
 {
     assert('is_cstring($url)', vs(isset($this), get_defined_vars()));
     assert('self::isValid($url, true)', vs(isset($this), get_defined_vars()));
     $this->m_url = $url;
     $parsedUrl = parse_url($url);
     assert('is_cmap($parsedUrl)', vs(isset($this), get_defined_vars()));
     // should not rise for a valid URL
     // Protocol (scheme).
     if (CMap::hasKey($parsedUrl, "scheme")) {
         $this->m_hasProtocol = true;
         $this->m_protocol = $parsedUrl["scheme"];
         // Normalize by converting to lowercase.
         $this->m_normProtocol = CString::toLowerCase($this->m_protocol);
     } else {
         $this->m_hasProtocol = false;
         $this->m_normProtocol = self::DEFAULT_PROTOCOL;
         if (!CMap::hasKey($parsedUrl, "host")) {
             // Most likely, `parse_url` function has not parsed the host because the protocol (scheme) is absent
             // and there are no "//" in the front, so try parsing the host with the default protocol in the URL.
             $parsedUrl = parse_url(self::ensureProtocol($url));
             assert('is_cmap($parsedUrl)', vs(isset($this), get_defined_vars()));
             CMap::remove($parsedUrl, "scheme");
         }
     }
     // Host (domain).
     $this->m_hostIsInBrackets = false;
     if (CMap::hasKey($parsedUrl, "host")) {
         $this->m_host = $parsedUrl["host"];
         if (CRegex::find($this->m_host, "/^\\[.*\\]\\z/")) {
             // Most likely, an IPv6 enclosed in "[]".
             $this->m_hostIsInBrackets = true;
             $this->m_host = CString::substr($this->m_host, 1, CString::length($this->m_host) - 2);
         }
         // Normalize by converting to lowercase.
         $this->m_normHost = CString::toLowerCase($this->m_host);
     } else {
         // Same as invalid.
         assert('false', vs(isset($this), get_defined_vars()));
     }
     // Port.
     if (CMap::hasKey($parsedUrl, "port")) {
         $this->m_hasPort = true;
         $this->m_port = $parsedUrl["port"];
         // Should be `int`, but look into the type just in case.
         if (is_cstring($this->m_port)) {
             $this->m_port = CString::toInt($this->m_port);
         }
     } else {
         $this->m_hasPort = false;
     }
     // Path.
     if (CMap::hasKey($parsedUrl, "path")) {
         $this->m_hasPath = true;
         $this->m_path = $parsedUrl["path"];
         // Normalize by replacing percent-encoded bytes of unreserved characters with their literal equivalents and
         // ensuring that all percent-encoded parts are in uppercase.
         $pathDelimitersReEsc = CRegex::enterTd(self::$ms_delimiters);
         $this->m_normPath = CRegex::replaceWithCallback($this->m_path, "/[^{$pathDelimitersReEsc}]+/", function ($matches) {
             return CUrl::enterTdNew(CUrl::leaveTdNew($matches[0]));
         });
     } else {
         $this->m_hasPath = false;
         $this->m_normPath = "/";
     }
     $this->m_urlPath = new CUrlPath($this->m_normPath);
     // Query string.
     $this->m_hasQuery = false;
     if (CMap::hasKey($parsedUrl, "query")) {
         $this->m_hasQuery = true;
         $this->m_queryString = $parsedUrl["query"];
         $parsingWasFruitful;
         $this->m_urlQuery = new CUrlQuery($this->m_queryString, $parsingWasFruitful);
         if ($parsingWasFruitful) {
             $this->m_hasQuery = true;
             $this->m_normQueryString = $this->m_urlQuery->queryString(true);
         }
     }
     // Fragment ID.
     if (CMap::hasKey($parsedUrl, "fragment")) {
         $this->m_hasFragmentId = true;
         $this->m_fragmentId = $parsedUrl["fragment"];
         // Normalize by replacing percent-encoded bytes of unreserved characters with their literal equivalents and
         // ensuring that all percent-encoded parts are in uppercase.
         $fiDelimitersReEsc = CRegex::enterTd(self::$ms_delimiters);
         $this->m_normFragmentId = CRegex::replaceWithCallback($this->m_fragmentId, "/[^{$fiDelimitersReEsc}]+/", function ($matches) {
             // Use the newer flavor of percent-encoding.
             return CUrl::enterTdNew(CUrl::leaveTdNew($matches[0]));
         });
     } else {
//.........这里部分代码省略.........
开发者ID:nunodotferreira,项目名称:Phred,代码行数:101,代码来源:CUrl.php

示例3: testLeaveTdNew

 public function testLeaveTdNew()
 {
     $this->assertTrue(CUrl::leaveTdNew("Hello+%20there+%2B~%7E")->equals("Hello+ there++~~"));
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:4,代码来源:CUrlTest.php


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