1、smarty配置文件:(直接继承smarty类)

<?php
require('/libs/Smarty.class.php');

class SmartyMistake extends Smarty {
 function __construct() {
  parent::__construct();
  $this->template_dir = 'templates/';
  $this->compile_dir = 'templates_c/';
  $this->cache_dir = 'cache/';
  $this->cache_lifetime = 0;
  $this->caching = false;
  $this->left_delimiter = "{ff:";
  $this->right_delimiter = "/}"; 
  $this->caching = true;  //生成静态页必须开启,否则生成的静态页无动态内容
 }
}

2、模板处理页面(index.php)

$vv = "说句心里话";
$smarty->assign("result",$vv);
$smarty->display('templates/index.tpl');
$content = $smarty->fetch('index.tpl', null, null, false);
$fp = fopen('index.html', 'w');
fwrite($fp, $content);
fclose($fp);