本文整理汇总了PHP中Xml::escape方法的典型用法代码示例。如果您正苦于以下问题:PHP Xml::escape方法的具体用法?PHP Xml::escape怎么用?PHP Xml::escape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xml
的用法示例。
在下文中一共展示了Xml::escape方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addTags
/**
* Populates <variation-attribute-values> child elements, from a mapping of attribute values to names
*
* @param array $map
*/
public function addTags($map = [])
{
$xml = '';
foreach ($map as $id => $value) {
$xml .= '<variation-attribute-value value="' . Xml::escape($id) . '">
<display-value xml:lang="x-default">' . Xml::escape($value) . '</display-value>
</variation-attribute-value>';
}
$this->elements['variation-attribute-values'] = $xml;
}
示例2: setCustomAttributes
/**
* Populates <custom-attributes> child elements, from a mapping of attribute ids to values
* Values can be empty and still exported, however attributes with null values aren't exported
* Attributes are exported sorted alphabetically by id for consistency and ease of diffing exports...
*
* @param array $map
*/
public function setCustomAttributes(array $map)
{
ksort($map);
$xml = '';
foreach ($map as $key => $value) {
if (is_null($value)) {
continue;
}
$xml .= '<custom-attribute attribute-id="' . Xml::escape($key) . '">';
if (is_array($value)) {
foreach ($value as $individual) {
if (is_null($individual)) {
continue;
}
$xml .= '<value>' . Xml::escape($individual) . '</value>' . PHP_EOL;
}
} else {
$xml .= Xml::escape($value);
}
$xml .= '</custom-attribute>' . PHP_EOL;
}
$this->elements['custom-attributes'] = $xml;
}
示例3: setProducts
/**
* Only applies to Sets
*
* @param array $products
*/
public function setProducts(array $products = [])
{
$xml = '';
foreach ($products as $id) {
$xml .= '<product-set-product product-id="' . Xml::escape($id) . '" />' . PHP_EOL;
}
$this->elements['product-set-products'] = $xml;
}