smarty的compile_dir 路径问题

骄傲青蛙 2009-03-31 03:24:50
根目录下有templates templates_c configs cache文件夹 下面代码为何报错?

Fatal error: Smarty error: the $compile_dir '/templates_c/' does not exist, or is not a directory.




require_once('class/libs/Smarty.class.php');

$smarty=new Smarty();
$smarty->template_dir = '/templates/';
$smarty->compile_dir = '/templates_c/'; //把这个注解就不会报错,而templates_c里也会生成缓存文件,因为用了Smarty类的默认路径
$smarty->config_dir = '/configs/';
$smarty->cache_dir = '/cache/';
$smarty->display('header.html');

...全文
980 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhouzhengting1 2012-08-18
  • 打赏
  • 举报
回复
我也遇到同样的问题,看了楼上才知道怎么解决
china_rat 2010-04-05
  • 打赏
  • 举报
回复
最近,也遇到了同样的问题了,参考一下。
junsgo 2009-05-16
  • 打赏
  • 举报
回复
相对于你调用smarty 的根目录建个文件夹templates_c就行了
骄傲青蛙 2009-04-02
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 yunfeifan 的回复:]
/aa/bb 这个是绝对路径,不是相对路径,而且你最好用绝对路径
你可以使用
$_SERVER['DOCUMENT_ROOT']."/templates_c/" 这个样子来表示当前网站的根目录的templates_c 这个目录(虚拟主机)。
[/Quote]

对,我就是想要这样
wangc715 2009-04-01
  • 打赏
  • 举报
回复
查看smarty的templates_c指向
HD拾荒者 2009-04-01
  • 打赏
  • 举报
回复
今天刚写了个配置smarty的教程,你参考参考吧!http://hi.baidu.com/hdxiaopihai/blog/item/e8a859f0c99311a7a50f5230.html
yunfeifan 2009-04-01
  • 打赏
  • 举报
回复
/aa/bb 这个是绝对路径,不是相对路径,而且你最好用绝对路径
你可以使用
$_SERVER['DOCUMENT_ROOT']."/templates_c/" 这个样子来表示当前网站的根目录的templates_c 这个目录(虚拟主机)。
骄傲青蛙 2009-04-01
  • 打赏
  • 举报
回复
没人弄得明白??
rex100 2009-03-31
  • 打赏
  • 举报
回复
骄傲青蛙 2009-03-31
  • 打赏
  • 举报
回复
打印出来的是
/templates_c/这路径
骄傲青蛙 2009-03-31
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 yunfeifan 的回复:]
这个目录应该是没有的吧 /templates_c/ 表示你的系统的根目录,而不是你当前网站的根目录
[/Quote]

系统根目录? 网站当前根目录?
我用的是相对路径 代码如7楼
骄傲青蛙 2009-03-31
  • 打赏
  • 举报
回复


require_once('class/libs/Smarty.class.php');

$smarty=new Smarty();
$smarty->template_dir = '/templates/';
$smarty->compile_dir = '/templates_c/'; //把这行注解掉,就不报错了,而且在根目templates_c下也会生成缓存文件
$smarty->right_delimiter = '}-->';
$smarty->display('header.html');


jackydrl 2009-03-31
  • 打赏
  • 举报
回复
在生成smarty类的实例后指定一个模板缓存目录,即你的例子中的template_c,要保证这个目录是相对于你目前文件的
hqaht 2009-03-31
  • 打赏
  • 举报
回复
编译目录找不到,可以指定一下的
你可以打印出来看看你的编译目录名称 对应一下是否真的存在
枯桥断道 2009-03-31
  • 打赏
  • 举报
回复
templates_c/ 目录不存在
可能原因是目前指向错误,
echo $smarty-> $compile_dir;
看看路径是什么?然后看看是否真的存在这样的目录。
程序猿之殇 2009-03-31
  • 打赏
  • 举报
回复
/templates_c/
根目录没有这个目录
海诗美妆 2009-03-31
  • 打赏
  • 举报
回复
应该是php无法访问到根目录,
看看php.ini设定,是不是开启safe_mode的缘故。
yunfeifan 2009-03-31
  • 打赏
  • 举报
回复
这个目录应该是没有的吧 /templates_c/ 表示你的系统的根目录,而不是你当前网站的根目录

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧