smarty生成静态页面

字体大小: 中小 标准 ->行高大小: 标准
代码:
$content  = $smarty->fetch();
fopen();
fwrite();

代码:
ob_start();
$smarty->display();
ob_get_contents();
ob_end_clean();

1.php

<?php
require 'smarty/libs/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->caching = true;


$smarty->assign("hai","hailang");
//$smarty->display('index.tpl');
$output=$smarty->fetch('index.tpl');
$pagename="./news.html";
$fp=fopen($pagename,"w"); "w"打开文件方式为写入,文件指针置于于文件头,并将原文件长度设为0,若文件不存在,存创建之。
fwrite($fp,$output);
fclose($fp);
?>

index.tpl

{config_load file="config.conf"}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>{#title#}</title>
</head>
<body>

{$hai}

</body>

</html>

静态文件总算是生成 了,但是没有输出内容。问题是并不成取得文件名

此文章由 www.phpgz.com 收集整理 ,地址为: http://www.phpgz.com/htmls/972.html

大屏阅读,大屏评论.