codecamp

CodeIgniter 排版辅助函数

排版辅助函数

排版辅助函数文件包含了文本排版相关的一些函数。

加载辅助函数

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

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

可用函数

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

auto_typography($str[, $reduce_linebreaks = FALSE])

参数:

  • $str (string) -- Input string
  • $reduce_linebreaks (bool) -- Whether to reduce multiple instances of double newlines to two

返回: HTML-formatted typography-safe string

返回类型: string

格式化文本以便纠正语义和印刷错误的 HTML 代码。

这个函数是 CI_Typography::auto_typography 函数的别名。 更多信息,查看 排版类 。

Usage example:

$string = auto_typography($string);

注解

格式排版可能会消耗大量处理器资源,特别是在排版大量内容时。 如果你选择使用这个函数的话,你可以考虑使用 缓存 。

nl2br_except_pre($str)

参数:

  • $str (string) -- Input string

返回: String with HTML-formatted line breaks

返回类型: string

将换行符转换为 标签,忽略 标签中的换行符。除了对 标签中的换行处理有所不同之外,这个函数和 PHP 函数 nl2br() 是完全一样的。

使用示例:

$string = nl2br_except_pre($string);

entity_decode($str, $charset = NULL)

参数:

  • $str (string) -- Input string
  • $charset (string) -- Character set

返回: String with decoded HTML entities

返回类型: string

这个函数是 CI_Security::entity_decode() 函数的别名。 更多信息,查看 安全类 。

CodeIgniter 文本辅助函数
CodeIgniter URL 辅助函数
温馨提示
下载编程狮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; }