codecamp

CodeIgniter XML 辅助函数

XML 辅助函数

XML 辅助函数文件包含了用于处理 XML 数据的一些函数。

加载辅助函数

该辅助函数通过下面的代码加载:

$this->load->helper('xml');

可用函数

该辅助函数有下列可用函数:

xml_convert($str[, $protect_all = FALSE])

参数:

  • $str (string) -- the text string to convert
  • $protect_all (bool) -- Whether to protect all content that looks like a potential entity instead of just numbered entities, e.g. &foo;

返回: XML-converted string

返回类型: string

将输入字符串中的下列 XML 保留字符转换为实体(Entity):

  • 和号:&
  • 小于号和大于号:
  • 单引号和双引号:' "
  • 减号:-

如果 & 符号是作为实体编号的一部分,譬如: { ,该函数将不予处理。 举例:

$string = '<p>Here is a paragraph & an entity (&#123;).</p>';
$string = xml_convert($string);
echo $string;

输出结果:

&lt;p&gt;Here is a paragraph &amp; an entity (&#123;).&lt;/p&gt;
CodeIgniter URL 辅助函数
向 CodeIgniter 贡献你的力量
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }