无忧站长 >

PHP定时生成静态html首页

2019-11-01 14:45:28 
//这边的定时也是需要用户触发 否则 使用设置html">php计划任务的方法来实现的话资源耗费较大
<?php
$nowtime=time();
$pastsec = $nowtime – $_GET["t"];
if($pastsec<60)
{
exit; //1分钟更新一次,时间可以自己调整
}
ob_tart" title="start" >start(); //打开缓冲区
include(”index.php”);
$content = ob_get_contents(); //得到缓冲区的内容
$content .= “n<script language=javascript src=”f5.php?t=”.$nowtime.”"></script>”; //加上调用更新程序的代码
file_put_contents(”index.html”,$content);
if (!function_exists(”file_put_contents”))
{
function file_put_contents($fn,$fs)
{
$fp=fopen($fn,”w+”);
fputs($fp,$fs);
fclose($fp);
}
}