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


PHP Uri::getPort方法代碼示例

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


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

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

示例2: testPort

 public function testPort()
 {
     $uri1 = new Uri('http://example.com:80');
     $uri2 = new Uri('http://example.com:443');
     $uri3 = new Uri('https://example.com:80');
     $uri4 = new Uri('https://example.com:443');
     $this->assertEquals('', $uri1->getPort());
     $this->assertEquals(443, $uri2->getPort());
     $this->assertEquals(80, $uri3->getPort());
     $this->assertEquals('', $uri4->getPort());
 }
開發者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: testGetPort

 /**
  * @covers MediaCore\Uri::getPort
  */
 public function testGetPort()
 {
     $url = 'http://example.com:8080/path/to/directory?foo=bar';
     $uri = new Uri($url);
     $this->assertEquals('8080', $uri->getPort());
     $url = 'http://example.com/path/to/directory?foo=bar';
     $uri = new Uri($url);
     $this->assertNull($uri->getPort());
 }
開發者ID:mediacore,項目名稱:mediacore-client-php,代碼行數:12,代碼來源:UriTest.php

示例5: testSetGetPort

 public function testSetGetPort()
 {
     $port = '8080';
     $this->uri->setPort($port);
     $this->assertEquals($port, $this->uri->getPort());
 }
開發者ID:codeblanche,項目名稱:web,代碼行數:6,代碼來源:UriTest.php

示例6: testGetPortWithSchemeWithoutPort

 public function testGetPortWithSchemeWithoutPort()
 {
     $uri = new Uri('http', 'www.example.com');
     $this->assertNull($uri->getPort());
 }
開發者ID:goragod,項目名稱:kotchasan,代碼行數:5,代碼來源:UriTest.php

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