国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專(zhuān)注于服務(wù)器技術(shù)及軟件下載分享
分類(lèi)導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|VB|R語(yǔ)言|JavaScript|易語(yǔ)言|vb.net|

服務(wù)器之家 - 編程語(yǔ)言 - PHP教程 - CodeIgniter整合Smarty的方法詳解

CodeIgniter整合Smarty的方法詳解

2021-06-22 15:48LoveJulin PHP教程

這篇文章主要介紹了CodeIgniter整合Smarty的方法,結(jié)合實(shí)例形式分析了CodeIgniter3.0.3整合Smarty3.1.27的步驟與相關(guān)設(shè)置技巧,需要的朋友可以參考下

本文實(shí)例講述了CodeIgniter整合Smarty的方法。分享給大家供大家參考,具體如下:

CI3.0.2發(fā)布后感覺(jué)模板類(lèi)還是不怎么好用,而且不能編譯。Smarty功能強(qiáng)大,用習(xí)慣了Smarty標(biāo)簽,一般難以放棄,而且,是可以編譯文件執(zhí)行,速度快,我們可以把它們整合使用,彌補(bǔ)CI的模板功能的不足。我們整合使用的是CI版本3.0.3及 Smarty版本3.1.27。下面描述整合過(guò)程。

1、下載smarty-3.1.27

2 、解壓smarty-3.1.27到CI項(xiàng)目中的application\libraries下面,其他的文件刪除。

3、 在application\libraries目錄下創(chuàng)建Ci_smarty.php文件,代碼如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require(APPPATH.'libraries/smarty-3.1.27/libs/Smarty.class.php');
class Ci_smarty extends Smarty {
 protected $ci;
 public function __construct()
 {
 parent::__construct();
 $this->ci = & get_instance();
 $this->ci->load->config('smarty');//加載smarty的配置文件
 $this->cache_lifetime =$this->ci->config->item('cache_lifetime');
 $this->caching = $this->ci->config->item('caching');
 $this->config_dir = $this->ci->config->item('config_dir');
 $this->template_dir = $this->ci->config->item('template_dir');
 $this->compile_dir = $this->ci->config->item('compile_dir');
 $this->cache_dir = $this->ci->config->item('cache_dir');
 $this->use_sub_dirs = $this->ci->config->item('use_sub_dirs');
 $this->left_delimiter = $this->ci->config->item('left_delimiter');
 $this->right_delimiter = $this->ci->config->item('right_delimiter');
 }
}

4、在application\config目錄下創(chuàng)建配置文件smarty.php,代碼如下:

?
1
2
3
4
5
6
7
8
9
10
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$config['cache_lifetime'] = 60;
$config['caching'] = false;
$config['template_dir'] = APPPATH .'views';
$config['compile_dir'] = APPPATH .'views/template_c';
$config['cache_dir'] = APPPATH . 'views/cache';
$config['config_dir'] = APPPATH . 'views/config';
$config['use_sub_dirs'] = false; //子目錄變量(是否在緩存文件夾中生成子目錄)
$config['left_delimiter'] = '{';
$config['right_delimiter'] = '}';

5、在application\core創(chuàng)建MY_controller.php,代碼如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
class MY_controller extends CI_Controller {
 public function __construct() {
 parent::__construct();
 }
 public function assign($key,$val)
 {
 $this->ci_smarty->assign($key,$val);
 }
 public function display($html)
 {
 $this->ci_smarty->display($html);
 }
}

至此,配置整合工作over了,下面我們要驗(yàn)證是否配置成功。

7、修改application\controllers的Welcome.php,代碼如下:

?
1
2
3
4
5
6
7
8
9
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends MY_controller {
 public function index()
 {
 $test='ci 3.0.3 + smarty 3.1.27 配置成功';
 $this->assign('test',$test);
 $this->display('test.html');
 }
}

然后,在application\views下創(chuàng)建test.html文件,代碼如下:

?
1
{$test}

在瀏覽器地址欄中輸入:http://localhost/index.php/Welcome

結(jié)果顯示:

?
1
ci 3.0.3 + smarty 3.1.27 配置成功

大功告成!

希望本文所述對(duì)大家基于CodeIgniter框架的PHP程序設(shè)計(jì)有所幫助。

原文鏈接:http://www.cnblogs.com/LoveJulin/p/5258806.html

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 欧美精品不卡 | 午夜影院 | 一级片免费视频 | 精品国产乱码一区二区三区 | 狠狠操电影 | 一级二级在线观看 | 亚洲精品视频一区二区三区 | 精品精品 | 国产成人精品一区二区三区视频 | 久久人人爽人人爽人人片亚洲 | 天天看天天操 | 精品日韩在线 | 亚洲一区在线视频 | 久久久av亚洲男天堂 | 自拍视频网站 | 国产成人在线播放 | 精品国产一区二区三区久久久蜜月 | 久久这里只有国产精品 | 午夜国产视频 | 日本一区二区三区免费观看 | 久久成| 在线色网站 | 精品国产91亚洲一区二区三区www | 九九热视频精品在线观看 | 亚洲免费观看视频 | 久久久久久亚洲 | 国产大片在线观看 | 成年人免费看 | 午夜小电影 | 国产福利视频在线观看 | 欧美亚洲一区二区三区 | 亚洲日本在线观看视频 | 久久久国产精品视频 | 日韩精品免费观看 | 一区二区三区视频免费在线观看 | 亚洲视频一区二区 | 国产在线高清视频 | 久久久中文字幕 | 玖玖精品在线 | 美女视频黄的免费 | 日韩欧美中文在线观看 |