php Smarty模板生成html文檔的方法
更新時間:2010年04月12日 14:42:30 作者:
看過Smarty,感覺這個東西很好用,但是不知道怎么生成html文檔。今天在網(wǎng)上查了下,找了方法
下面直接發(fā)代碼
<?php
/*
file:config_smarty.php
done:配置Smarty
author:www.5dkx.com
date:2009-12-21
*/
include_once("../libs/smarty.class.php");
class MySmarty extends Smarty{
function __construct()
{
$this->Smarty();
$this->config_dir = "../config";
$this->cache_dir = "../cache";
$this->template_dir = "../template";
$this->compile_dir = "../template_c";
$this->cache = false;
}
}
$smart = new MySmarty();
$smart->assign("title","標(biāo)題");
$smart->assign("content","內(nèi)容");
$smart->display('article.tpl');
$output = $smart->fetch('article.tpl');
$Path = "../html/1.html";
$fp = fopen($Path,"w");
fwrite($fp,$output);
fclose($fp);
?>
復(fù)制代碼 代碼如下:
<?php
/*
file:config_smarty.php
done:配置Smarty
author:www.5dkx.com
date:2009-12-21
*/
include_once("../libs/smarty.class.php");
class MySmarty extends Smarty{
function __construct()
{
$this->Smarty();
$this->config_dir = "../config";
$this->cache_dir = "../cache";
$this->template_dir = "../template";
$this->compile_dir = "../template_c";
$this->cache = false;
}
}
$smart = new MySmarty();
$smart->assign("title","標(biāo)題");
$smart->assign("content","內(nèi)容");
$smart->display('article.tpl');
$output = $smart->fetch('article.tpl');
$Path = "../html/1.html";
$fp = fopen($Path,"w");
fwrite($fp,$output);
fclose($fp);
?>
您可能感興趣的文章:
- Smarty模板快速入門
- 在smarty模板中使用PHP函數(shù)的方法
- 模板引擎smarty工作原理以及使用示例
- 解析smarty模板中類似for的功能實現(xiàn)
- smarty模板中使用get、post、request、cookies、session變量的方法
- PHP模板引擎Smarty的緩存使用總結(jié)
- PHP模板引擎smarty詳細(xì)介紹
- smarty模板引擎中內(nèi)建函數(shù)if、elseif和else的使用方法
- smarty模板引擎中自定義函數(shù)的方法
- php之Smarty模板使用方法示例詳解
- PHP 基于Yii框架中使用smarty模板的方法詳解
- smarty模板的使用方法實例分析
相關(guān)文章
php使用Smarty的相關(guān)注意事項及訪問變量的幾種方式
使用Smarty的相關(guān)注意事項及訪問變量的幾種方式分享,需要的朋友可以參考下。2011-12-12需要使用php模板的朋友必看的很多個頂級PHP模板引擎比較分析
最近學(xué)習(xí)php模板技術(shù),找到一篇不錯的關(guān)于php模板的分析為了找到一個好的模板引擎,我在互聯(lián)網(wǎng)上進(jìn)行搜索,目前已經(jīng)整理出了以下名單2008-05-05