代码如下
$smarty = new Smarty;
$smarty->setTemplateDir('../../../website/templates/');
$smarty->setCompileDir('../../../website/templates_c/index/');
$smarty->setCacheDir('../../../website/cache/index/');
$smarty->clearCache('index.html');想删除index.html模板对应的缓存文件,但是一直删除不掉,使用clearAllCache方法倒是可以把index目录下的缓存都删了

解决方案 »

  1.   

    我把脚本文件放在根目录下,变成如下,就可以删除了;但是实际情况不可能把脚本单独放在根目录的,不知道到底是啥原因?
    $smarty = new Smarty;
    $smarty->setTemplateDir('website/templates/');
    $smarty->setCompileDir('website/templates_c/index/');
    $smarty->setCacheDir('website/cache/index/');
    $smarty->clearCache('index.html');
      

  2.   

    $smarty = new Smarty;
    $smarty->setTemplateDir('website/templates/');
    $smarty->setCompileDir('website/templates_c/index/');
    $smarty->setCacheDir('website/cache/index/');
    $smarty->clearCache('index.html');
    可以将参数的路径换成绝对路径试试realpath('../../../website/templates/')