这篇文章主要为大家详细介绍了php Smarty模板生成html的简单示例,具有一定的参考价值,可以用来参考一下。
感兴趣的小伙伴,下面一起跟随512笔记的小编小韵来看看吧!
下面直接发代码代码如下:
<?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);
?>
本文来自:http://www.512pic.com/173/13658-0.html
注:关于php Smarty模板生成html的简单示例的内容就先介绍到这里,更多相关文章的可以留意512笔记的其他信息。
关键词:
512笔记收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。