当前位置: 首页>>代码示例>>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;未经允许,请勿转载。