用ob_系列"输出控制函数"函数 ob_start();
............
............
//捕捉输出
$content=ob_get_contents(); ob_end_clean();
//再写入文件
function wfile($file,$content,$mode='w') {
$oldmask = umask(0);
$fp = fopen($file, $mode);
if (!$fp) return false;
fwrite($fp,$content);
fclose($fp);
umask($oldmask);
return true;
}wfile("文件名",$content);
或者用模板http://www.phpe.net/?n=ReadArticle&a=7 http://www.phpe.net/?n=ReadArticle&a=220
............
............
//捕捉输出
$content=ob_get_contents(); ob_end_clean();
//再写入文件
function wfile($file,$content,$mode='w') {
$oldmask = umask(0);
$fp = fopen($file, $mode);
if (!$fp) return false;
fwrite($fp,$content);
fclose($fp);
umask($oldmask);
return true;
}wfile("文件名",$content);
或者用模板http://www.phpe.net/?n=ReadArticle&a=7 http://www.phpe.net/?n=ReadArticle&a=220
参考:超越模板引擎
http://www.phpe.net/articles/384.shtml
to love01px() 谢谢你的回复,我知道 单个页面 可以用ob_系列"输出控制函数"函数或模板实现静态化,
但我转不过弯来的是:
比如在一个页面上有个连结点样式<a href=newshow.php?id=224>NEWS</a>(此页面也模板化生成了静态页面)
我把newshow.php?id=224也已经模板化生成了静态页面为../20050602/224.html了,
我的问题就是怎样把这个新生成的(../20050602/224.html)页面和原连结点 NEWS 链接起来,使页面连接点变成<a href=../20050602/224.html>NEWS</a>
像sports.sina.com.cn中的新闻列表的样式,http://sports.sina.com.cn/g/2005-06-03/19161595137.shtml
我也不知道我描述清楚了没,也不知道可不可以实现
$html = preg_replace("/newshow\.php\?id=(\d+)/","../20050602/\\1.html",$html);
谢谢大兄弟的热心回复,我想知道你对这样的问题整个处理过程,可以麻烦你写一下整个处理流程吗?我真的很想知道,再谢!(如果有更好的实现方法,万望不惜赐教,不要局限于我的思路)