首先index.php
<?php
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->template_dir= 'D:/APMXE5/htdocs/hust/MySmarty/templates'; 
$smarty->config_dir = 'D:/APMXE5/htdocs/hust/MySmarty/configs'; 
$smarty->cache_dir = 'D:/APMXE5/htdocs/hust/MySmarty/cache'; 
$smarty->compile_dir = 'D:/APMXE5/htdocs/hust/MySmarty/templates_c'; 
$smarty->assign('name','跟17PHP学安装Smarty'); 
$smarty->caching = true;
$smarty->display('index.tpl'); ?> 
运行后没有问题!!
...........................................................................
下面我把基本设置写成了一个类,在调用:
setup.php
<?php 
// load Smarty library
require('Smarty.class.php');// The setup.php file is a good place to load
// required application library files, and you
// can do that right here. An example:
// require('guestbook/guestbook.lib.php');是一个很好的加载应用程序的类库文件(就是扩展类)
//例如你可以在index文件里包含它class Smarty_GuestBook extends Smarty { function Smarty_GuestBook() {
 
  // Class Constructor. These automatically get set with each new instance.
 //类构造函数.创建实例的时候自动配置 $this->Smarty();
$smarty->template_dir= 'D:/APMXE5/htdocs/hust/MySmarty/templates/'; 
        $smarty->config_dir = 'D:/APMXE5/htdocs/hust/MySmarty/configs/'; 
        $smarty->cache_dir = 'D:/APMXE5/htdocs/hust/MySmarty/cache/'; 
        $smarty->compile_dir = 'D:/APMXE5/htdocs/hust/MySmarty/templates_c/'; 
$this->caching = true;
$this->assign('name','跟17PHP学安装Smarty'); 
 }}?>
.........................................................................
index.php<?phprequire('setup.php');$smarty = new Smarty_GuestBook;$smarty->assign('name','Ned');$smarty->display('index.tpl');?> 运行后出现一下错误:
Fatal error: Smarty error: the $cache_dir 'cache' does not exist, or is not a directory. in d:\Smarty\libs\Smarty.class.php on line 1095
高手看看这是什么问题呢???