|
本文介绍下,用php定时生成静态html首页的一例代码,有需要的朋友参考下。
用php定时生成静态页面。 代码如下:
<?php
//定时生成静态页
//需要用户初始触发
//by bbs.it-home.org
$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”; //加上调用更新程序的代码
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);
}
}
?>登录后复制 |
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号