是这样的,class.smarttemplate.php有一个bug
你需要将
unset ($_top);
改为
unset ($GLOBALS[_top]);只有这一处在output方法中
你需要将
unset ($_top);
改为
unset ($GLOBALS[_top]);只有这一处在output方法中
解决方案 »
- PHP执行MSSQL存储过程如何获得返回值
- $rows['0']和$rows['yuwen']的问题
- 怎么样才能把多个文件的名称、文件被上传后在服务器段存储的临时文件名同时insert into 到数据库的一个表中呢
- 实现对存储过程的统一访问
- php+xml xsltll xdomxml.dll 架不起来,
- 请大家提供一些好的系统学习PHP的网站,最好有教程
- iframe 问题,求救!
- php&sqlserver2000问题
- php如何和js结合修改客户端的系统时间?我想同步我公司所有机器的时间,他们每天上班先要访问网页,还有能否测出某个IP是否在线?就像ping的功能一样?
- CSDN的分涨的蛮快嘛!
- eclipse支持php要装那个插件?
- addslashes没法把"替换成\"
不过我看output方法中并没有对$_top是数组的情况进行处理,
也就是说声明$_top是全局的没有起到什么作用吧。
如果不想使用模板嵌套的功能去掉他就行了吧
$tpl 是一个class的实例.
也就是说 $tpl->assign("a",$a);
是让$tpl中的一个变量a等于$a
和$a = a; 是一样的..
你用循环就=====
for($i=0;$i<10:i++){
$a = "a";
}
是不可能 让$a 就变成一个数组
我是在刚接触到这个东西,也发现类似的问题时在网上找到的答案至于为什么要声明$_top我并没有认真研究 function output ( $_top = '' )
{
global $_top; // Make sure that folder names have a trailing '/'
if (strlen($this->template_dir) && substr($this->template_dir, -1) != '/')
{
$this->template_dir .= '/';
}
if (strlen($this->temp_dir) && substr($this->temp_dir, -1) != '/')
{
$this->temp_dir .= '/';
}
// Prepare Template Content
if (!is_array($_top))
{
if (strlen($_top))
{
$this->tpl_file = $_top;
}
$_top = $this->data;
}
$_obj = &$_top;
$_stack_cnt = 0;
$_stack[$_stack_cnt++] = $_obj; // Check if template is already compiled
$this->cpl_file = $this->temp_dir . preg_replace('/[:\/.\\\\]/', '_', $this->tpl_file) . '.php';
$compile_template = true;
if ($this->reuse_code)
{
if (is_file($this->cpl_file))
{
if ($this->mtime($this->cpl_file) > $this->mtime($this->template_dir . $this->tpl_file))
{
$compile_template = false;
}
}
}
if ($compile_template)
{
include_once ("class.smarttemplateparser.php");
$this->parser = new SmartTemplateParser($this->template_dir . $this->tpl_file);
if (!$this->parser->compile($this->cpl_file))
{
exit( "SmartTemplate Compiler Error: " . $this->parser->error );
}
}
// Execute Compiled Template
include($this->cpl_file); // Delete Global Content Array in order to allow multiple use of SmartTemplate class in one script
// unset ($_top);
unset ($GLOBALS[_top]);
}
再次感谢唠叨老大!
结贴