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


PHP Uri::getFragment方法代碼示例

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


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

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

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

示例4: testGetFragment

 /**
  * @covers MediaCore\Uri::getFragment
  */
 public function testGetFragment()
 {
     $url = 'http://www.example.org/foo.html#bar';
     $uri = new Uri($url);
     $this->assertEquals('bar', $uri->getFragment());
 }
開發者ID:mediacore,項目名稱:mediacore-client-php,代碼行數:9,代碼來源:UriTest.php

示例5: testSetGetFragment

 public function testSetGetFragment()
 {
     $fragment = 'fragmentation';
     $this->uri->setFragment($fragment);
     $this->assertEquals($fragment, $this->uri->getFragment());
 }
開發者ID:codeblanche,項目名稱:web,代碼行數:6,代碼來源:UriTest.php

示例6: testSetFragment

 public function testSetFragment()
 {
     $uri = new Uri('http', 'www.yahoo.com', '/', null, 'foo');
     $this->assertEquals('foo', $uri->getFragment());
     $this->assertEquals('http://www.yahoo.com/#foo', $uri->toString());
 }
開發者ID:seytar,項目名稱:psx,代碼行數:6,代碼來源:UriTest.php


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