ob缓存

来源:互联网 发布:linux sysctl 优化 编辑:程序博客网 时间:2024/04/30 08:15
ob_start();                            //打开缓冲区if(!is_file("a.html")||time()-filemtime("a.html")>1200){    //10秒后可以再次缓存   $brr = "风力:".$arr['fengli']."<br>温度:".$arr['wendu']."℃";echo $brr;   $content = ob_get_contents();          //取得php页面输出的全部内容   $fp = fopen("a.html", "w");       //创建一个文件,并打开,准备写入   fwrite($fp, $content);                 //把php页面的内容全部写入output00001.html,然后……   fclose($fp);}else{   echo "缓存:";   echo file_get_contents("a.html");}
0 0
原创粉丝点击