<?php
$_time =5;
$dir="E:\\flandy\\";
function cache_start($_time, $dir)
{
$cachefile = $dir.'/'.sha1($_SERVER['REQUEST_URI']).'.html';
$cachetime = $_time;
ob_start();
if(file_exists($cachefile) && (time( )-$cachetime < filemtime($cachefile)))
{
include($cachefile);
ob_end_flush();
exit;
}
}
function cache_end($dir)
{
$cachefile = $dir.'/'.sha1($_SERVER['REQUEST_URI']).'.html';
$fp = fopen($cachefile, 'w');
fwrite($fp, ob_get_contents());
fclose($fp);
ob_end_flush();
}
cache_start($_time, $dir);
//以下是输出的内容,放在cache_start和cache_end两个方法之间
for($i=0;$i<=100;$i++)
{
for($j=0;$j<=$i;$j++)echo $j."-";
echo "<br>";
}
cache_end($dir);
?>