<?php /**ob_start(); ob_get_contents(); ob_end_flush(); ** **php頁面緩存的使用方法,php頁面緩存的小例子,如果數(shù)據(jù)庫查詢量較大,可以用cache來解決 **/ function cache_start($dir,$expiretime){ $filename = $dir.'\\'.sha1($_SERVER['REQUEST_URI']).'.html'; ob_start(); if(file_exists($filename) && (time()- filemtime($filename)<$expiretime)){ include($filename); ob_end_flush(); exit(); } mkdir($dir); } function cache_end($dir){ $filename = $dir.'\\'.sha1($_SERVER['REQUEST_URI']).'.html'; echo $filename; $fp = fopen($filename,'w'); fwrite($fp,ob_get_contents()); fclose($fp); ob_end_flush(); } $dir = "D:\\\\php"; cache_start($dir, 10); cache_end($dir);
網(wǎng)站欄目:php頁面緩存的使用方法
鏈接URL:http://chinadenli.net/article48/pghohp.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站排名、面包屑導航、關鍵詞優(yōu)化、建站公司、微信小程序、網(wǎng)站策劃
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)