日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

php codeigniter 语言,php – codeigniter模板引擎,包括语言解析器

發布時間:2023/11/27 生活经验 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php codeigniter 语言,php – codeigniter模板引擎,包括语言解析器 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

不幸的是,CI內置的模板解析器類沒有此功能.你可以在

sparks directory中環顧四周,有多個火花集成了許多模板引擎,如smarty或twig,可以通過調整來創建這樣的東西.

此外,您可以嘗試擴展CI_Parser類來為您執行此操作,如下所示:

class MY_Parser extends CI_Parser {

const LANG_REPLACE_REGEXP = '!\{_\s*(?[^\}]+)\}!';

public $CI = null;

public function parse($template, $data, $return = FALSE) {

$this->CI = get_instance();

$template = $this->CI->load->view($template, $data, TRUE);

$template = $this->replace_lang_keys($template);

return $this->_parse($template, $data, $return);

}

protected function replace_lang_keys($template) {

return preg_replace_callback(self::LANG_REPLACE_REGEXP, array($this, 'replace_lang_key'), $template);

}

protected function replace_lang_key($key) {

return $this->CI->lang->line($key[1]);

}

}

這將使用$this-> lang-> line(‘password’)替換{_ password}之類的部分.可以針對您喜歡的版本調整模式.

將其置于application / libraries / MY_Parser.php和CI之下應該選擇它,不需要更改控制器代碼,如Extending Native Libraries部分所述.

總結

以上是生活随笔為你收集整理的php codeigniter 语言,php – codeigniter模板引擎,包括语言解析器的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。