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


PHP Uri::getScheme方法代码示例

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


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

示例1: getPattern

 /**
  * Returns a pattern representing an uri. It can be used to check if two urls have the same
  * equivalence class.
  *
  * @return string
  */
 public function getPattern()
 {
     // file type
     $pattern = $this->getFileType() . ':';
     // schema (http, https)
     $pattern .= $this->uri->getScheme() . ':';
     // host
     $pattern .= $this->uri->getHost() . ':';
     $path = $this->uri->getPath() . '?' . $this->uri->getQuery();
     $pathNew = preg_replace("^[a-f0-9]{32}^", "<h>", $path);
     $pathNew = preg_replace("^[a-z\\-\\_]{1,}^i", "<s>", $pathNew);
     $pathNew = preg_replace("^[0-9]{1,}^", "<i>", $pathNew);
     $pattern .= $pathNew;
     return $pattern;
 }
开发者ID:phmlabs,项目名称:crawler,代码行数:21,代码来源:PatternAnalyzer.php

示例2: testConstructor

 public function testConstructor()
 {
     $uri = new Uri('http://user:password@example.com:81/foo/bar?a=2&b=3#baz');
     $this->assertEquals('http', $uri->getScheme());
     $this->assertEquals('example.com', $uri->getHost());
     $this->assertEquals('/foo/bar', $uri->getPath());
     $this->assertEquals(81, $uri->getPort());
     $this->assertEquals('user:password', $uri->getUserInfo());
     $this->assertEquals('a=2&b=3', $uri->getQuery());
     $this->assertEquals('baz', $uri->getFragment());
 }
开发者ID:jivoo,项目名称:http,代码行数:11,代码来源:UriTest.php

示例3: testShouldParseUriWithPortSuccessful

 public function testShouldParseUriWithPortSuccessful()
 {
     $case = 'http://www.example.com:3232/payments/1?foo=bar&baz=bar#order';
     $uri = new Uri($case);
     $this->assertEquals(3232, $uri->getPort());
     $this->assertEquals('www.example.com', $uri->getHost());
     $this->assertEquals('http', $uri->getScheme());
     $this->assertNotEmpty($uri->getPath());
     $this->assertEquals('/payments/1', $uri->getPath());
     $this->assertNotEmpty($uri->getQuery());
     $this->assertEquals('foo=bar&baz=bar', $uri->getQuery());
     $this->assertNotEmpty($uri->getFragment());
     $this->assertEquals('order', $uri->getFragment());
     $this->assertEquals($case, $uri->__toString());
 }
开发者ID:everypay,项目名称:everypay_prestashop_1_6_x,代码行数:15,代码来源:UriTest.php

示例4: __construct

 public function __construct($url = NULL, $method = 'GET', array $options = array())
 {
     if (!is_null($url)) {
         $uri = new Uri($url);
         if ($uri->getScheme() == '') {
             $url = 'http://' . $url;
         }
         $this->request = new Request($method, $url);
         $this->request = $this->request->withHeader('Expect', '');
         $this->request = $this->request->withHeader('Connection', 'close');
         $this->request = $this->request->withHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
         if (array_key_exists(CURLOPT_HTTPHEADER, $options) && is_array($options[CURLOPT_HTTPHEADER])) {
             foreach ($options[CURLOPT_HTTPHEADER] as $header) {
                 $buf = explode(':', $header, 2);
                 $this->request = $this->request->withHeader($buf[0], ltrim($buf[1]));
             }
         }
     }
     $this->options = $options;
 }
开发者ID:jejem,项目名称:http-client,代码行数:20,代码来源:Client.php

示例5: factory

 /**
  * Create a URI from a string
  *
  * @param  string $uriString
  * @param  string $defaultScheme
  * @throws Exception\InvalidArgumentException
  * @return \Zend\Uri\Uri
  */
 public static function factory($uriString, $defaultScheme = null)
 {
     if (!is_string($uriString)) {
         throw new Exception\InvalidArgumentException(sprintf('Expecting a string, received "%s"', is_object($uriString) ? get_class($uriString) : gettype($uriString)));
     }
     $uri = new Uri($uriString);
     $scheme = strtolower($uri->getScheme());
     if (!$scheme && $defaultScheme) {
         $scheme = $defaultScheme;
     }
     if ($scheme && !isset(static::$schemeClasses[$scheme])) {
         throw new Exception\InvalidArgumentException(sprintf('no class registered for scheme "%s"', $scheme));
     }
     if ($scheme && isset(static::$schemeClasses[$scheme])) {
         $class = static::$schemeClasses[$scheme];
         $uri = new $class($uri);
         if (!$uri instanceof UriInterface) {
             throw new Exception\InvalidArgumentException(sprintf('class "%s" registered for scheme "%s" does not implement Zend\\Uri\\UriInterface', $class, $scheme));
         }
     }
     return $uri;
 }
开发者ID:adrenth,项目名称:rssfetcher,代码行数:30,代码来源:UriFactory.php

示例6: resolve

 /**
  * @param string $toResolve
  * @return Uri
  * @link http://tools.ietf.org/html/rfc3986#section-5.2.2
  */
 public function resolve($toResolve)
 {
     $r = new Uri($toResolve);
     if ($r->__toString() === '') {
         return clone $this;
     }
     $base = $this;
     $t = new \StdClass();
     $t->scheme = '';
     $t->authority = '';
     $t->path = '';
     $t->query = '';
     $t->fragment = '';
     if ('' !== $r->getScheme()) {
         $t->scheme = $r->getScheme();
         $t->authority = $r->getAuthority();
         $t->path = $this->removeDotSegments($r->getPath());
         $t->query = $r->getQuery();
     } else {
         if ('' !== $r->getAuthority()) {
             $t->authority = $r->getAuthority();
             $t->path = $this->removeDotSegments($r->getPath());
             $t->query = $r->getQuery();
         } else {
             if ('' == $r->getPath()) {
                 $t->path = $base->getPath();
                 if ($r->getQuery()) {
                     $t->query = $r->getQuery();
                 } else {
                     $t->query = $base->getQuery();
                 }
             } else {
                 if ($r->getPath() && substr($r->getPath(), 0, 1) == "/") {
                     $t->path = $this->removeDotSegments($r->getPath());
                 } else {
                     $t->path = $this->mergePaths($base->getPath(), $r->getPath());
                 }
                 $t->query = $r->getQuery();
             }
             $t->authority = $base->getAuthority();
         }
         $t->scheme = $base->getScheme();
     }
     $t->fragment = $r->getFragment();
     $result = $this->reconstitute($t->scheme, $t->authority, $t->path, $t->query, $t->fragment);
     return new Uri($result);
 }
开发者ID:softwarevamp,项目名称:artax,代码行数:52,代码来源:Uri.php

示例7: testGetScheme

 /**
  * @covers MediaCore\Uri::getScheme
  */
 public function testGetScheme()
 {
     $url = 'http://example.com/path/to/directory?foo=bar';
     $uri = new Uri($url);
     $this->assertEquals('http', $uri->getScheme());
 }
开发者ID:mediacore,项目名称:mediacore-client-php,代码行数:9,代码来源:UriTest.php

示例8: testSetGetScheme

 public function testSetGetScheme()
 {
     $scheme = 'ftp';
     $this->uri->setScheme($scheme);
     $this->assertEquals($scheme, $this->uri->getScheme());
 }
开发者ID:codeblanche,项目名称:web,代码行数:6,代码来源:UriTest.php

示例9: testSetScheme

 public function testSetScheme()
 {
     $uri = new Uri('https', 'www.yahoo.com');
     $this->assertEquals('https', $uri->getScheme());
     $this->assertEquals('https://www.yahoo.com', $uri->toString());
 }
开发者ID:seytar,项目名称:psx,代码行数:6,代码来源:UriTest.php

示例10: buildResolvedUriAgainst

 private function buildResolvedUriAgainst(Uri $uri)
 {
     $scheme = $uri->getScheme();
     $authority = $uri->getAuthority();
     $path = $uri->getPath();
     $query = $uri->getQuery();
     if ($this->getAuthority()) {
         $authority = $this->getAuthority();
         $path = $this->getPath();
         $query = $this->getQuery();
     } elseif ($this->getPath()) {
         $path = $this->buildResolvedPathAgainst($uri->getPath());
         $query = $this->getQuery();
     } elseif ($this->getQuery()) {
         $query = $this->getQuery();
     }
     return $this->appendRelativeParts("{$scheme}://{$authority}{$path}", $query, $this->parts['fragment']);
 }
开发者ID:stefk,项目名称:jval,代码行数:18,代码来源:Uri.php


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