<?php
define("WOB","smarty/libs/");
include(WOB."Smarty.class.php");
$smarty = new Smarty;//设置各个目录的路径,这里是安装的重点
$smarty->template_dir ="smarty/templates/templates";
$smarty->compile_dir ="smarty/templates/templates_c";
$smarty->config_dir = "smarty/templates/config";
$smarty->cache_dir ="smarty/templates/cache";
$smarty->left_delimiter="<--{"; $smarty->right_delimiter="}-->";
$smarty->caching = false;
$foo = $smarty->get_template_vars('foo');
$sql="select * from cct where id='".$foo."'";
$smarty->assign("name",$foo[0]);
$smarty->assign("namer",$foo[1]);
$content=$smarty->fetch("2.tpl");
$title="./2.html";
MfileText($title,$content);
function MfileText($Mtitle,$Content) {
if(!file_exists(dirname($Mtitle))) {
if(!@mkdir(dirname($Mtitle),0777)) {
die($Mtitle."false");
}
}
if(!$tp=fopen($Mtitle,"w")) {
echo "false"; return false;
}
if(!fwrite($tp,$Content)) {
echo "file write false";
fclose($tp); return false;
} fclose($tp);
chmod($Mtitle,0666);
}
?>
2.tpl代码:
<--{assign var="foo" value="6"}--><--{$name}--><br /><--{$namer}-->