国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

php ob_start() ob_end_flush()緩存技術簡單應用

2024-05-04 21:58:56
字體:
來源:轉載
供稿:網友

本文章介紹了一個簡單的關于php入門篇-緩存技術簡單應用,有需要的朋友可以看看,這里是利用了ob_start(); ob_end_flush(); 來實例的,代碼如下:

  1. <?php  
  2. // define the path and name of cached file  
  3. $cachefile = 'cached-files/'.date('M-d-Y').'.php';  
  4. // define how long we want to keep the file in seconds. I set mine to 5 hours.  
  5. $cachetime = 18000;  
  6. // Check if the cached file is still fresh. If it is, serve it up and exit.  
  7. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {  
  8. include($cachefile);  
  9. exit;  
  10. }  
  11. // if there is either no file OR the file to too old, render the page and capture the HTML. //開源代碼Vevb.com 
  12. ob_start();  
  13. ?>  
  14. <html>  
  15. output all your html here.  
  16. </html>  
  17. <?php  
  18. // We're done! Save the cached content to a file  
  19. $fp = fopen($cachefile'w');  
  20. fwrite($fp, ob_get_contents());  
  21. fclose($fp);  
  22. // finally send browser output  
  23. ob_end_flush();  
  24. ?>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 陆川县| 阿克陶县| 重庆市| 巴青县| 儋州市| 天津市| 乐安县| 武胜县| 淮阳县| 城固县| 南昌市| 雷波县| 卢龙县| 长阳| 固原市| 新巴尔虎左旗| 津市市| 青州市| 台安县| 黄陵县| 北海市| 安徽省| 石柱| 南宁市| 永清县| 永城市| 尼勒克县| 佳木斯市| 珲春市| 平舆县| 鄂伦春自治旗| 孝感市| 盐池县| 即墨市| 萝北县| 阿克| 新野县| 进贤县| 大洼县| 苏州市| 枝江市|