在你的动态php页面最顶端放置代码:<?php ob_start(); ?>
然后在页面最底部放置代码:<?php
$info = ob_get_contents();
$filectime = filectime("index.html"); //自动生成的页面
if ( !(time() - 10 > $filectime) ) { //频繁刷新限制10S,不限制设置为0即可
ob_end_clean();
exit();
}
if ( $handle = @fopen('index.html', 'w') ) { //自动生成的页面
@fwrite($handle, $info);
@fclose($handle);
}
?>
比如你的页面是index.php 设置生成的页面是index.html 那么,你手动访问下index.php页面就可以自动生成html页面了。
部分主机配置环境影响不会自动生成,那么就需要加个监控来实现了。这个就自己琢磨吧!
注意:此方法不建议添加多个php页面中,很消耗服务器资源的,有时间我发个优化版出来。