关于template的菜鸟问题

huanxiong0101 2005-04-12 02:34:47
我建了一个xdjl虚拟目录~
template.inc放在xdjl->commonfunction目录下
如果我要创建一个实例是不是应该这样写
<?
require "../commonfunction/template.inc";
$tpl = new Template("../commonfucntion/template","remove");
?>
但是运行的时候出现错误:
Template Error: set_root: ../commonfunction/Template is not a directory.
谁知道是怎么回事吗?
...全文
176 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
huanxiong0101 2005-04-12
  • 打赏
  • 举报
回复
搞定了,谢谢可爱钟,你的方法很好
huanxiong0101 2005-04-12
  • 打赏
  • 举报
回复
恩,可以了,我把目录弄错了
/*test.php*/
<?php
//包含进模板类 template.inc
require "../commonfunction/template.inc";
//创建一个实例
//$tpl = new Template("../commonfunction/template.inc/template","remove");
$tpl = new Template("","remove");
//将整个文件读进来
/********************************************************
运行到这里出问题了
说是../body/top.php不存在~ not exist
我的目录结构是
xdjl->body->top.php
xdjl->depart->test.php
xdjl->commonfunction->template.inc
***********************************************************/
$tpl->set_file("my_header", "../body/top.php");
$tpl->set_file("my_footer", "../body/foot.php");
$tpl->parse("header", "my_header");
$tpl->parse("footer", "my_footer");
//完成主模板内变量的替换
$tpl->parse("mains", "main");
//输出
$tpl->p("mains");
?>
谁帮我指点指点
keaizhong 2005-04-12
  • 打赏
  • 举报
回复
建议楼主不要把目录搞得这么复杂,请先行在同一目录练习一下。
搞懂之后你想用什么目录都行。
huanxiong0101 2005-04-12
  • 打赏
  • 举报
回复
问题是我写成
$tpl = new Template("template","remove");

$tpl = new Template("./commonfunction/template","remove");

$tpl = new Template("././xdjl/commonfunction/template","remove");
都不正确~
coolwindkaka 2005-04-12
  • 打赏
  • 举报
回复
这是PHP吧。。。用类的话应该跟ASP差不多吧,也是$tpl = new Template(注:Template为类名),对吗,讲错了别骂我啊

21,891

社区成员

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

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