smarty基础应用源码
来源:互联网 发布:阿沁淘宝店真假 编辑:程序博客网 时间:2024/05/22 03:26
index.php
<?php/*//直接在本文件中配置//库文件包含define('SMARTY_DIR','D:/APMServ5.2.6/www/htdocs/smartydemo/smarty/');require(SMARTY_DIR.'smarty.class.php');//配置$smarty = new Smarty;$smarty->compile_dir = SMARTY_DIR.'templates_c/';$smarty->cache_dir = AMARTY_DIR.'cache/';$smarty->template_dir = 'templates/';$smarty->config_dir = 'config/';$this->caching = true;//变量传值$smarty->assign('name', 'phf');//显示模板文件$smarty->display('index.tpl');//$smarty->display('index.tpl', 2);//多份缓存*//* //取出生成的文件$file = $smarty->fetch('index.tpl');echo $file;*//*//单个文件的cache时间设置$smarty->caching = 2; // lifetime is per cache$smarty->cache_lifetime = 300;$smarty->display('index.tpl');*/// 实初化配置的进一步类封装require_once('smartydemo.class.php');$smarty = new Smarty_demo;$smarty->assign('name', 'phf');//$smarty->display('index.tpl');$smarty->display('index.tpl', 2);
smartydemo.class.php
<?php//define('SMARTY_DIR','D:/APMServ5.2.6/www/htdocs/smartydemo/smarty/');require(SMARTY_DIR.'smarty.class.php');class Smarty_demo extends Smarty{function __construct(){Smarty::__construct();$this->compile_dir = SMARTY_DIR.'templates_c/';$this->cache_dir = SMARTY_DIR.'cache/';$this->template_dir = 'templates/';$this->config_dir = 'config/';$this->caching = true;$this->cache_lifetime = 1;$this->assign('app_name','smartydemo');}}
index.tpl
{* smarty *}<h1>{$app_name}</h1>hello {$name}!;
- smarty基础应用源码
- smarty教程-smarty入门基础应用实例教程
- Smarty应用
- 应用smarty
- smarty应用
- Smarty应用
- smarty基础
- smarty基础
- Smarty-基础
- smarty基础
- Zend Framework+smarty应用
- smarty模板应用入门
- smarty foreach应用
- Smarty模板引擎应用
- 应用smarty分页
- smarty缓存的应用
- smarty安装和应用
- smarty安装及应用
- 实例恢复时间
- CSRF攻击方式-跨站请求伪造攻击
- opencv-图像缩放
- C++虚函数表解析
- linux root用户密码破解
- smarty基础应用源码
- c语言的extern和static
- 总线协议类(总结接触到的总线类型)
- Qt setInputMask 掩码含义
- 微指数批量查询工具V1.0发布了
- AlarmManager手机闹钟服务
- maven setting.xml 详解
- Singleton单例模式
- 【Java学习笔记】基础知识学习18【一个小文件的复制方法】