<?php
define('BASE_PATH',$_SERVER['DOCUMENT_ROOT']);
define('SMARTY_PATH','\PHP\Smarty\\');require BASE_PATH.SMARTY_PATH.'Smarty.class.php';$smarty=new Smarty;
$smarty->template_dir=BASE_PATH.SMARTY_PATH.'templates/';
$smarty->complie_dir=BASE_PATH.SMARTY_PATH.'templates_c/';
$smarty->config_dir=BASE_PATH.SMARTY_PATH.'configs/';
$smarty->cache_dir=BASE_PATH.SMARTY_PATH.'cache/';$smarty->assign('title','第一个Smarty程序!');
$smarty->assign('content','hello,welcome to study\'smarty\'!');$smarty->display('index.html');?>
这是Smarty的配置但是运行起来总报错,下面是错误语句。
Fatal error: Smarty error: the $compile_dir 'templates_c' does not exist, or is not a directory. in D:\AppServ\www\PHP\Smarty\Smarty.class.php on line 1092
Smarty.class.php的存在目录是:D:\AppServ\www\PHP\Smarty
找了好久,一直找不出原因,求高手解决!!!

解决方案 »

  1.   

    compile_dir、templates_c路径没指对
    BASE_PATH.SMARTY_PATH 变量搞错了吧?
    调试 输出看看
      

  2.   

    错误信息表示你声明的目录不存在配置 Smarty 工作目录不需要绝对路径,只需要用相对于 Smarty。class.php 做在目录的相对目录即可
      

  3.   

    BASE_PATH.SMARTY_PATH 输出看看,保证你模板文件和编译文件在同级