<?php $template_name = 'TemplateDemo'; //模版文件夹名 require_once('includes/smarty/Smarty.class.php'); //包含smarty类文件 $smarty=new Smarty; //初始化Smarty $smarty->compile_check = true; //打开模版编译检查 $smarty->debugging = false; //关闭调试 $smarty->caching = false; //关闭缓存 $smarty->template_dir = "template/{$template_name}/"; //设置模版路径 $smarty->compile_dir = 'template_c'; //设置编译文件存放的文件夹 $smarty->left_delimiter = '{{'; //设置左边界符 $smarty->right_delimiter = '}}'; //设置右边界符号 $smarty->assign('Name' , 'Smarty模板程序!'); //smarty方法,用来把模板里的{{$Name}}部分用变量'Smarty模板程序!替换。 $smarty->display('Demo.tpl'); //输出模板 ?>