smartyを使用したページキャッシュの生成

5825 ワード

01.php
 //  smarty
 include "libs/Smarty.class.php";

 $smarty = new Smarty;

//        
 $smarty -> setTemplateDir("./view/");
 $smarty -> setCompileDir("./view_c/");

 //    
 $smarty -> caching = 1;

 $brand = $_GET['brand'];
 $price = $_GET['price'];
 $network = $_GET['network'];
 $big = $_GET['big'];

// display(  ,mark1|mark2|mark3|mark4)
 $smarty ->display('01.html',$brand."|".$price."|".$network."|".$big);

 /*
 clearCache(    ); //              
 clearCache(  ,  ); //       ,             
 clearCache(); //        
 clearCache(null,  ) //               ,         
  */

01.html

<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>smarty    title>
 head>
 <body>
    <h2>smarty    h2>
    <ul>
        :<br/>
    <h1>  h1> 
    :{$smarty.get.brand}<br/>
    :{$smarty.get.price}<br/>
    :{$smarty.get.network}<br/>
    :{$smarty.get.big}<br/>
    ul>
 body>
html>

02.phpクリアキャッシュ
 //  smarty
 include "libs/Smarty.class.php";

 $smarty = new Smarty;

 $smarty -> setTemplateDir("./view/");
 $smarty -> setCompileDir("./view_c/");
 /*
 clearCache(    ); //              
 clearCache(  ,  ); //       ,             
 clearCache(); //        
 clearCache(null,  ) //               ,         

  */
 echo $smarty -> clearCache('07.html','htc|1|cmcc|4');