如果是使用核心版的话,将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>