復制代碼 代碼如下:
<?php
//在你的開始處加入 ob_start();
ob_start();
//以下是你的代碼
//在結尾加入 ob_end_clean(),并把本頁輸出到一個變量中
$temp = ob_get_contents();
ob_end_clean();
//寫入文件
$fp = fopen(‘文件名','w');
fwrite($fp,$temp) or die(‘寫文件錯誤');
?>
復制代碼 代碼如下:
if(file_exists(“xxx.html”))
{
$time = time();
//文件修改時間和現在時間相差半小時一下的話,直接導向html文件,否則重新生成html
if($time - filemtime(“xxx.html”) < 30*60)
{
header(“Location:xxx.html”);
}
}
//在你的開始處加入 ob_start();
ob_start();
//頁面的詳細內容
//在結尾加入 ob_end_clean(),并把本頁輸出到一個變量中
$temp = ob_get_contents();
ob_end_clean();
//寫入文件
$fp = fopen(‘xxx.html','w');
fwrite($fp,$temp) or die(‘寫文件錯誤');
//重新導向
header(“Location:xxx.html”);
新聞熱點
疑難解答