如何实现页面静态化

ob_start();
phpinfo();
$content = ob_get_contents(); //取得php页面输出的全部内容
ob_clean();
$fp = fopen("index.html", "w"); //创建一个文件,并打开,准备写入
fwrite($fp, $content); //把php页面的内容全部写入output00001.html,然后……
fclose($fp);

//filemtime() 函数返回文件内容上次的修改时间。
if(is_file("./index.html") && time()-filemtime("./index.html") < 300){//5分钟内的页面
return require_once("./index.html");
}else{
//更新新的数据
}

file_put_contents('index.html',$data)

你可能感兴趣的:(如何实现页面静态化)