php Smarty模板生成html文档的方法

2019/6/30 15:28:42

本文主要是介绍php Smarty模板生成html文档的方法,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

下面直接发代码
复制代码 代码如下:

<?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","内容");
$smart->display('article.tpl');
$output = $smart->fetch('article.tpl');
$Path = "../html/1.html";
$fp = fopen($Path,"w");
fwrite($fp,$output);
fclose($fp);
?>


这篇关于php Smarty模板生成html文档的方法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程