21,881
社区成员
发帖
与我相关
我的任务
分享
<?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不能赋值
?>
<div class="logo"><?php echo $show ?></div>
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);
}
<?php
require "system/system.php";
$tpl = new KSeeing();
$tpl->assign("show",'success');
//$show = '111';
//include('templates/index.html');
//include('F:/AppServ/www/temp/tpl/com_index.html.php');
$tpl->compile('index.html');
?>
<?php
require "system/system.php";
$tpl = new KSeeing();
$tpl->assign("show",'success');
//$show = '111';
include('templates/index.html');
//include('F:/AppServ/www/temp/tpl/com_index.html.php');
$tpl->compile('index.html');
?>
目前的终极页面可以正常输出success 这是没问题的 然后我稍加修改
<?php
require "system/system.php";
$show = '111';
$tpl->compile('index.html');
?>
这样index.html里的$show就没值了,问题来了!!!如果我把$tpl->compile('index.html');改成
include('templates/index.html');就好使了!!而$tpl->compile('index.html');得到的结果也是include('templates/index.html');或者是绝对路径 这样为啥就不好使了呢 目前表面问题看着像页面问题 extract($this->data);
include($comFile);