執行個體:實現動態網頁的靜態緩衝_PHP教程

來源:互聯網
上載者:User

執行個體:實現動態網頁的靜態緩衝


源動態網頁

  1. <title>執行個體:實現動態網頁的靜態緩衝title>
  2. <h3>執行個體:實現動態網頁的靜態緩衝h3>
  3. <p>
  4. <chtml>
  5. <for end=0 start=20>
  6. <b>@{int:@{for:getSuffix}+1}-b>
  7. <forendforendforendforend=@{for:getSuffix}>
  8. <fontcolorfontcolorfontcolorfontcolor=red>@{int:@{for:getSuffix}+1}-font>
  9. for>
  10. <br>
  11. for>
  12. chtml>
  13. p>

(例子檔案:_samples/file_page.html)

讀緩衝的靜態檔案資訊

  1. <file act=info>WEB-INF/cache/page_test.htmlfile>

判斷靜態檔案是否存在

  1. <if x="@{file:exists}"else=0>
  2. <call>pagecall>
  3. <callxcallxcallxcallx=true>cachecall>
  4. if>

存在就調用cache,不存在則調用page

  1. <call>pagecall>
  2. <call x=true>cachecall>

可調用標籤cache,讀快取檔案

  1. <chtml onlycallid=cache>
  2. <file act=read method=str name=page>WEB-INF/cache/page_test.htmlfile>
  3. chtml>

可調用標籤page

  1. <chtml id=page file="@{sys:curPath}file_page.html" save="WEB-INF/cache/page_test.html" onlycall />

引入動態網頁檔案@{sys:curPath}file_page.html,並儲存為WEB-INF/cache/page_test.html檔案

顯示緩衝內容

@{file:page}

完整代碼

  1. <html>
  2. <chtml>
  3. <file act=info>WEB-INF/cache/page_test.htmlfile>
  4. <if x="@{file:exists}" else=0>
  5. <call>pagecall>
  6. <call x=true>cachecall>
  7. if>
  8. chtml>
  9. <chtml id=page file="@{sys:curPath}file_page.html" save="WEB-INF/cache/page_test.html" onlycall />
  10. <chtml onlycall id=cache>
  11. <file act=read method=str name=page>WEB-INF/cache/page_test.htmlfile>
  12. chtml>@{file:page}
  13. html>

效果

(例子檔案:_samples/file_cache.html)

抓緊體驗體驗吧!

http://www.bkjia.com/PHPjc/964931.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/964931.htmlTechArticle執行個體:實現動態網頁的靜態緩衝 源動態網頁 title 執行個體:實現動態網頁的靜態緩衝 / title h3 執行個體:實現動態網頁的靜態緩衝 / h3 p chtml for e...

  • 聯繫我們

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