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


PHP Uri::getHost方法代码示例

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


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

 public function withUri(Uri $uri, bool $preserveHost = false) : HttpRequest
 {
     $request = clone $this;
     $request->uri = $uri;
     $host = $uri->getHost();
     if ($host != '') {
         $host .= $uri->getPort() ? ':' . $uri->getPort() : '';
         if ($preserveHost) {
             if (empty($request->getHeader('Host'))) {
                 $request = $request->withHeader('Host', $host);
             }
         } else {
             $request = $request->withHeader('Host', $host);
         }
     }
     return $request;
 }
开发者ID:koolkode,项目名称:async-http,代码行数:17,代码来源:HttpRequest.php

示例5: _fetch

 protected function _fetch(&$counter, $params)
 {
     $result = parent::_fetch($counter, $params);
     $uri = new Uri($_SERVER['PHP_SELF']);
     foreach ($result as $key => $data) {
         $nav_uri = new Uri($data['url']);
         if ($uri->getHost() != $nav_uri->getHost()) {
             continue;
         }
         if (is_integer($res = $uri->comparePath($nav_uri))) {
             if ($res >= 0) {
                 $result[$key]['in_path'] = true;
             }
             if ($res == 0) {
                 $result[$key]['selected'] = true;
             }
         }
     }
     return $result;
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:20,代码来源:SimpleNavigationDatasource.class.php

示例6: testGetHost

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

示例7: testSetGetHost

 public function testSetGetHost()
 {
     $host = 'somenewhost';
     $this->uri->setHost($host);
     $this->assertEquals($host, $this->uri->getHost());
 }
开发者ID:codeblanche,项目名称:web,代码行数:6,代码来源:UriTest.php

示例8: testSetPort

 public function testSetPort()
 {
     $uri = new Uri('http', 'www.yahoo.com:8080');
     $this->assertEquals('www.yahoo.com:8080', $uri->getAuthority());
     $this->assertEquals('www.yahoo.com', $uri->getHost());
     $this->assertEquals(8080, $uri->getPort());
     $this->assertEquals('http://www.yahoo.com:8080', $uri->toString());
 }
开发者ID:seytar,项目名称:psx,代码行数:8,代码来源:UriTest.php


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