Home > Backend Development > PHP Tutorial > Code sharing for php to generate static html regularly

Code sharing for php to generate static html regularly

WBOY
Release: 2016-07-25 08:57:33
Original
1014 people have browsed it
This article introduces an example code that uses PHP to regularly generate a static HTML homepage. Friends in need can refer to it.

Use php to generate static pages regularly.

The code is as follows:

<?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);      
    }
}
?>
Copy after login


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template