Example #1
0
 /**
  * 模版方法
  *
  * @return string
  */
 public function display($path, $array = [])
 {
     if (C('CACHE')) {
         $ext = ".php";
         $cfile = md5($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
         $file = CACHE_DATA_PATH . '/' . $cfile . $ext;
         if (file_exists($file) && filemtime($path) < filemtime($file)) {
             include $file;
         } else {
             ob_start();
             extract($array);
             include Template::tpl($path);
             if (!file_put_contents($file, ob_get_contents())) {
                 throwexce(sprintf('Cache file error, check the directory “%s” writable', CACHE_DATA_PATH));
             }
             ob_end_flush();
         }
     } else {
         extract($array);
         include Template::tpl($path);
     }
 }