友情提示:此篇文章大约需要阅读 1分钟28秒,不足之处请多指教,感谢您的阅读。 订阅本站
Smarty是PHP的一个引擎模板,主要是用于前台动态文章嵌套,实现动态链接数据库并显示的作用。
在慕课网上学来的,叫做“五配置两方法”。
$smarty = new Smarty();
//Smarty “自编口诀-五配置两方法”
//五配置介绍
$smarty -> left_delimiter = "{";
//左定界符
$smarty -> right_delimiter = "}";
//右定界符
$smarty -> template_dir = "tpl";
//html模板的地址
$smarty -> compile_dir = "template_c";
//模板编译生成的文件
$smarty -> cache_dir = "cache";
//缓存
//以下是开启缓存的另外两个配置/因为通常不用Smarty的缓存机制,所以此项为了解 $smarty -> caching = true;
//开启缓存
$smarty -> cache_lifetime = 120;
$smarty->assign('articletitle', '文章标题');
$smarty->display('test.tpl');
发表回复