smarty半小时快速上手入门教程
本文讲述了smarty快速上手入门的方法,可以让读者在半小时内快速掌握smarty的用法。分享给大家供大家参考。具体实现方法如下:
一、smarty的程序设计部分:
在smarty的模板设计部分我简单的把smarty在模板中的一些常用设置做了简单的介绍,这一节主要来介绍一下如何在smarty中开始我们程序设计。下载Smarty文件放到你们站点中。
index.php代码如下:
<?php
/**
*
*@version$Id:index.php
*@package
*@authorwww.nhooo.com
*@action显示实例程序
*/
include_once("./Smarty/Smarty.class.php");//包含smarty类文件
$smarty=newSmarty();//建立smarty实例对象$smarty $smarty->templates("./templates");//设置模板目录 $smarty->templates_c("./templates_c");//设置编译目录 $smarty->cache("./cache");//缓存目录 $smarty->cache_lifetime=0;//缓存时间 $smarty->caching=true;//缓存方式
$smarty->left_delimiter="{#"; $smarty->right_delimiter="#}"; $smarty->assign("name","zaocha");//进行模板变量替换 $smarty->display("index.htm");//编译并显示位于./templates下的index.htm模板 ?>
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短