PHP有关问题请大神帮忙

PHP问题【急】【急】【急】【急】请大神帮忙
本帖最后由 sysmaze 于 2014-11-02 15:47:57 编辑
模板赋值问题
最终页代码如下

<?php 
    require "system/system.php"; 
    $tpl =  new KSeeing();
    $tpl->assign("show",'success');
    $show = '111';
    include('templates/index.html');  =======================这样写的话 $show能成功赋值
    //include('F:/AppServ/www/temp/tpl/com_index.html.php'); 
    //$tpl->compile('index.html');===================这样写的话$show不能赋值
?>

index.html 简要代码如下 输出一个变量

<div class="logo"><?php  echo $show ?></div>


问题如下:
                直接在本页面下include(上面第一个代码块)   include('templates/index.html');  成功赋值可以输出$show值
                简单写了个模板 核心函数 $tpl->compile('index.html'); 如下  就不能成功赋值 相对绝对路径都试过,【以下代码compile已改为绝对】,而且两个引用的路径一模一样[非绝对下]竟然不好使!!!不知道是不是涉及到GLOBAL这个东西,请大神详解 ,在线等!


function compile($fileName){
            $ducument_root = $_SERVER['DOCUMENT_ROOT'];
            $tplFile = $ducument_root.$this->template_dir.$fileName; //找到模版文件
            if(!file_exists($tplFile)){
                return false;
            }
            $comFile = $ducument_root.$this->compile_dir.'com_'.basename($tplFile).'.php';//构造编译后的文件
            if(!file_exists($comFile) || filemtime($comFile)<filemtime($tplFile)){
                $repContent  = $this->tpl_replace(file_get_contents($tplFile));//获取源文件内容并替换成php源格式
                $handle = fopen($comFile,'w+');
                fwrite($handle,$repContent);
                fclose($handle);
            }
            include($comFile);
        }



------解决思路----------------------
你的 KSeeing::assign 方法是怎么写的?

一般的说
$tpl->assign("show",'success'); 
是将 'success' 赋予 $tpl 的 show 属性,通常会有一个载体
所以可能是这样 $tpl->data['show'] = 'success';

你的模板中是 <?php  echo $show ?>
所以 compile 方法中应是
extract($this->data);
include($comFile);