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","標題");
$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);
?>
復制代碼 代碼如下:
<?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","標題");
$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詳細介紹
- 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 Ctemplate引擎開發(fā)相關(guān)內(nèi)容
因為公司需要,我們后面的項目將采用Php Ctemplate引擎開發(fā)。在這里,我只是將我這一個月學習到的,和自己的理解寫出來。如果有不正確,或者描述不準確的地方,希望大家能批評指出2012-03-03
最簡便的MySql數(shù)據(jù)庫備份方法MySQLdump
2008-01-01
PHP簡單系統(tǒng)數(shù)據(jù)添加以及數(shù)據(jù)刪除模塊源文件下載
今天我們總結(jié)一下PHP簡單信息系統(tǒng)MySQL中數(shù)據(jù)添加模塊以及刪除模塊的學習內(nèi)容。2008-06-06

