CodeIgniter 排版輔助函數(shù)

2018-07-21 15:44 更新

排版輔助函數(shù)

排版輔助函數(shù)文件包含了文本排版相關(guān)的一些函數(shù)。

加載輔助函數(shù)

該輔助函數(shù)通過下面的代碼加載:

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

可用函數(shù)

該輔助函數(shù)有下列可用函數(shù):

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

參數(shù):

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

返回: HTML-formatted typography-safe string

返回類型: string

格式化文本以便糾正語義和印刷錯(cuò)誤的 HTML 代碼。

這個(gè)函數(shù)是 CI_Typography::auto_typography 函數(shù)的別名。 更多信息,查看 排版類 。

Usage example:

$string = auto_typography($string);

注解

格式排版可能會(huì)消耗大量處理器資源,特別是在排版大量內(nèi)容時(shí)。 如果你選擇使用這個(gè)函數(shù)的話,你可以考慮使用 緩存 。

nl2br_except_pre($str)

參數(shù):

  • $str (string) -- Input string

返回: String with HTML-formatted line breaks

返回類型: string

將換行符轉(zhuǎn)換為 標(biāo)簽,忽略 標(biāo)簽中的換行符。除了對(duì) 標(biāo)簽中的換行處理有所不同之外,這個(gè)函數(shù)和 PHP 函數(shù) nl2br() 是完全一樣的。

使用示例:

$string = nl2br_except_pre($string);

entity_decode($str, $charset = NULL)

參數(shù):

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

返回: String with decoded HTML entities

返回類型: string

這個(gè)函數(shù)是 CI_Security::entity_decode() 函數(shù)的別名。 更多信息,查看 安全類 。

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)