php真靜態緩衝 ob系統函數 php 函數傳回值 php 數組 php date函

來源:互聯網
上載者:User
真靜態緩衝:(真的產生一個html頁面,在接下來的操作中直接調用該html)
第一次(重新整理網頁面)判斷是否存在快取檔案 (可設定一時間)
如果不存在 第一次是(可根據PDO)串連資料庫 尋找資料 輸出到頁面 並且同時緩衝(寫入)到本地一個.html檔案;
再次(重新整理網頁面) 判斷是否存有該快取檔案時
當存在快取檔案,直接尋找本機快取(file_get_content) 讀取出來

以下代碼在ci架構中編寫完成

$time = 10; //設定快取頁面面到期時間if(!is_file("obtest.html") || time()-filemtime("obtest.html")>$time){ob_start();       //開啟緩衝區   $arr['res']=$this->db->get('user')->result_array();$this->load->view('welcome_message',$arr);//print_r($arr);$info = ob_get_contents();       //得到緩衝區的內容並且賦值給$info   $file = fopen('obtest.html', 'w');  //開啟檔案info.txt   fwrite($file, $info);       //寫入資訊到info.txt   fclose($file);          //關閉檔案info.txt}else{    echo "cache:";    echo file_get_contents("obtest.html");}

fopen 和 filemtime 方法的使用:

fopen() 函數開啟檔案或者 URL。fopen(檔案名稱,檔案訪問類型)w寫入方式開啟。filemtime() 函數返迴文件內容上次的修改時間,裡面跟檔案名稱。

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('
  • ').text(i)); }; $numbering.fadeIn(1700); }); });

    以上就介紹了php真靜態緩衝 ob系統函數,包括了php,函數方面的內容,希望對PHP教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.