这是PHP吧用类的话应该跟ASP差不多吧,也是$tpl = new Template(注:Template为类名),对吗,讲错了别骂我啊

解决方案 »

  1.   

    问题是我写成
    $tpl = new Template("template","remove");

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

    $tpl = new Template("././xdjl/commonfunction/template","remove");
    都不正确~
      

  2.   

    恩,可以了,我把目录弄错了
    /*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"); 
    ?> 
    谁帮我指点指点