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


PHP Sitemap::encode方法代碼示例

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


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

示例1: set_loc

 /**
  * URL of the page. This URL must begin with the protocol (such as http) and end
  * with a trailing slash, if your web server requires it. This value must be
  * less than 2,048 characters.
  * @see http://www.sitemaps.org/protocol.php
  * @param string $location
  */
 public function set_loc($location)
 {
     if (!Validate::max_length($location, 2048)) {
         throw new LengthException('The location was too long, maximum length of 2,048 characters.');
     }
     $location = Sitemap::encode($location);
     if (!Validate::url($location)) {
         throw new InvalidArgumentException('The location was not a valid URL');
     }
     $this->attributes['loc'] = $location;
     return $this;
 }
開發者ID:hkilter,項目名稱:OpenSupplyChains,代碼行數:19,代碼來源:url.php

示例2: test_create

 /**
  * @test
  * @group sitemap
  * @dataProvider provider_create
  * @param string $location
  * @param integer $lastmod
  * @param string $change_frequency
  * @param integer|float $priority
  */
 public function test_create($location, $lastmod, $change_frequency, $priority)
 {
     $instance = new Sitemap_URL();
     $instance->set_loc($location)->set_last_mod($lastmod)->set_change_frequency($change_frequency)->set_priority($priority);
     $return = $instance->create();
     // This solution allows me to see failure results displayed in the
     // CLI runner. Using assertTag or assertSelectEquals only gives me a boolean
     // value back and makes it very hard to track down errors.
     $xml = simplexml_import_dom($return);
     $this->assertEquals(Sitemap::encode($location), (string) $xml->loc);
     $this->assertEquals(Sitemap::date_format($lastmod), (string) $xml->lastmod);
     $this->assertEquals($change_frequency, (string) $xml->changefreq);
     $this->assertEquals($priority, (string) $xml->priority);
 }
開發者ID:HappyKennyD,項目名稱:teest,代碼行數:23,代碼來源:UrlTest.php

示例3: test_encode

 /**
  * @test
  * @group sitemap
  * @dataProvider provider_encode
  */
 public function test_encode($string, $expected)
 {
     $return = Sitemap::encode($string);
     $this->assertSame($expected, $return);
 }
開發者ID:HappyKennyD,項目名稱:teest,代碼行數:10,代碼來源:DataTest.php


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