回去又想了半天,觉得这是一个能否把一个句柄传递到
另一个函数或者类里面再传出来的问题.不知道可不可行.好象用全局变量是没用的.

解决方案 »

  1.   

    不很理解你的担忧<?php
    include "template.inc";
    $tpl = new template("../idedata");
    $tpl->set_file(array("head"=>"tpl.tpl","body"=>"tpl.tpl","teil"=>"tpl.tpl"));$tpl->set_var("value","头");
    $tpl->parse("out","head",true);$tpl->set_var("value","中段");
    $tpl->parse("out","body",true);$tpl->set_var("value","尾");
    $tpl->parse("out","teil",true);$tpl->p("out");
    ?>
    tpl.tpl
    这是{value}<br>如果要把
    $tpl->set_var("value","头");
    $tpl->parse("out","head",true);
    放在函数(或类的方法)里处理
    则函数这样定义
    function foo(&$tpl) {
      $tpl->set_var("value","头");
      $tpl->parse("out","head",true);
    }
      

  2.   

    感谢老大的回复,精彩之极,谢谢了:)