php 緩衝技術

來源:互聯網
上載者:User

<?php$ct = 3600;                                     ////////設定緩衝時間$currpage = isset($_GET['p']) ? $_GET['p'] : 1;$cf = "cache/pok$currpage.html";$iscache = false;                               ////////設定緩衝是否開啟的條件if($iscache && file_exists($cf) && (time()-filemtime($cf)<=$ct)){  //////////判斷是否滿足緩衝開始的條件    include $cf;                                                    /////// 滿足條件 查看cache下面的html靜態頁面}else{                                                              //      如果不滿足 則執行php檔案    ob_start();                                                     //////開啟 緩衝    require 'common/conn.php';    require 'common/util.php';?><!doctype html><html><head><meta charset="utf-8"><title>無標題文檔</title><style>div.pager { width: 660px; height: 50px; margin: 0 auto; padding-left: 300px; }div.pager a { color:#000000; font-family: 宋體; font-size: 12px; border: 1px solid #Dedcdc; padding: 1px 6px; line-height: 25px; display: block; float: left; margin-right: 5px; text-decoration: none; }div.pager a:hover { border:1px solid #bcbcbc;color: green; font-size: 12px; }div.pager span.curr { display: block; font-size: 12px; padding: 1px 6px; line-height: 27px; display: block; float: left; margin-right: 5px; font-weight: 800; }div.pager span.spans { display: block; color: gray; font-size: 10px; line-height: 25px; padding-top: 5px; margin-right: 6px; display: block; float: left; }</style></head><body><?php$currpage = isset($_GET['p']) ? $_GET['p'] : 1;$r = pager($m,'st2',$currpage,15,'sname,sage');while($row = $r[0]->fetch_row()){    printf("姓名:%s,年齡:%d<br/>",$row[0],$row[1]);  }echo $r[4];$m->close();?></body></html><?php    $html = ob_get_contents();                                      /////////緩衝關閉    file_put_contents($cf,$html);                                   /////////輸出快取檔案到cache目錄中}?>


本文出自 “mysql_php_apache” 部落格,請務必保留此出處http://johnzxw.blog.51cto.com/4510670/1299932

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.