01 | if ( file_exists ( "./index.htm" )) //看静态index.htm文件是否存在{ |
02 | $time =time(); |
03 |
04 | //文件修改时间和现在时间相差?的话,直接导向htm文件,否则重新生成htm |
05 | if ( $time - filemtime ( "./index.htm" )< 600){ |
06 | header( "Location:classhtml/main.htm" ); |
07 | } |
08 | } |
09 |
10 | //在你的开始处加入ob_start(); |
11 | ob_start(); |
12 |
13 | //首页内容,就是你的动态部分了 |
14 |
15 | //在结尾加入ob_end_clean(),并把本页输出到一个变量中 |
16 | $temp =ob_get_contents(); |
17 | ob_end_clean(); |
18 |
19 | //写入文件 |
20 | $fp = fopen ( "./index.htm" , 'w' ); |
21 | fwrite( $fp , $temp ) or die ( '写文件错误' ); |
22 | //echo"生成HTML完成!"; |
欢迎大家阅读《php自动生产静态页_php》,跪求各位点评,若觉得好的话请收藏本文,by 搞代码