本文整理汇总了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;
}
示例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);
}
示例3: test_encode
/**
* @test
* @group sitemap
* @dataProvider provider_encode
*/
public function test_encode($string, $expected)
{
$return = Sitemap::encode($string);
$this->assertSame($expected, $return);
}