是这样的,class.smarttemplate.php有一个bug
你需要将
unset ($_top);
改为
unset ($GLOBALS[_top]);只有这一处在output方法中
你需要将
unset ($_top);
改为
unset ($GLOBALS[_top]);只有这一处在output方法中
解决方案 »
- 刚安装完的apache进到localhost内想看到目录怎么解决,急
- 请问动网论坛中的附件怎么删除啊?
- 正则表达式去空格提问
- 本人菜鸟,按照书本和网上的介绍在xp下搭建php+apache+mysql,可是显示mysql没有连接成功,请各位指教
- linux 下 Mysql 数据访问量也不是很大,为什么老是死掉,要重启数据库才能访问 !
- session 在页面跳转 session 的值变成空了了?
- PHP远程调用Matlab
- smarty+php+linux 页面打开一片空白的问题
- 如何让php和sqlserver联系起来
- 用事务处理 真的会提高速度吗
- 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]);
}
再次感谢唠叨老大!
结贴