您的位置:首页 > 编程语言 > PHP开发

ThinkPHP使用Smarty

2015-09-13 22:51 666 查看
如果是使用核心版的话,将Smarty文件夹放置在/ThinkPHP/Library/Vendor中

然后配置Application/Home/Conf/config.php 

return array(
//'配置项'=>'配置值'
'TMPL_ENGINE_TYPE'=>'Smarty' ,
'TMPL_ENGINE_CONFIG'=>array(
'left_delimiter'=>'{{', //左分界符
'right_delimiter'=>'}}' //右分界符
),
);

Application\Home\Controller\IndexController.class.php 中写代码

namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
public function index(){
$name="张三";
$this->assign("name",$name);
$this->display();
}
}


新建模板 :Application\Home\View\Index\index.html
<!doctype html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>ThinkPHP测试</title>
</head>
<body>
姓名:{{$name}}
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  smarty thinkphp