700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > CI框架整合smarty步骤详解 – PHP基础 – 前端 php代码格式化无效

CI框架整合smarty步骤详解 – PHP基础 – 前端 php代码格式化无效

时间:2019-05-13 22:28:51

相关推荐

CI框架整合smarty步骤详解 – PHP基础 – 前端 php代码格式化无效

smarty的模板机制很强大,一般情况下CI无需整合其他模板标签,因为PHP本身就是一种标签,简单易用。codeigniter整合smarty教程(偶用的都是最新版本)如下:

第一步:下载codeigniter最新版本:/downloads

第二步:下载smarty最新版本:/download

第三步:

配置步骤:

(1)将smarty拷贝到application/libraries下,然后再根目录下下新建templates,templates_c,config,cache目录,结构如下:

(2)入口文件新增:define(‘ROOT’, dirname(__FILE__));

(3)libraries下新建CI_Smarty.php

$value) { $this->$key = $value; } } else { //ROOT是Codeigniter在入口文件index.php定义的本web应用的根目录 $this->template_dir = $template_dir ? $template_dir : ROOT . ‘/templates’; $this->compile_dir = $compile_dir ? $compile_dir : ROOT . ‘/templates_c’; $this->config_dir = $config_dir ? $config_dir : ROOT . ‘/config’; $this->cache_dir = $cache_dir ? $cache_dir : ROOT . ‘/cache’; } } }

controller中使用:

load->library(‘CI_Smarty’); } public function test() { $this->ci_smarty->assign(‘test’, ‘smarty’); $this->ci_smarty->display(‘test.tpl’); }} /* End of file welcome.php *//* Location: ./application/controllers/welcome.php */

新建test.tpl模板:

这是 {$test} 测试

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。