【发布时间】:2010-10-12 21:40:42
【问题描述】:
我在控制器中有以下代码:
$data['what'] = 'test';
$this->load->view('test_view', $data);
$this->load->view('test_view');
查看:
<?php
echo $what;
?>
运行这段代码的结果是:
testtest
不应该只是“测试”,因为我第二次没有传递变量 $data 吗? 如何让 CodeIgniter 以这种方式运行?
编辑1:
我已经为这个问题想出了一个临时的解决方法:
在Loader.php中替换:
/*
* Flush the buffer... or buff the flusher?
*
* In order to permit views to be nested within
* other views, we need to flush the content back out whenever
* we are beyond the first level of output buffering so that
* it can be seen and included properly by the first included
* template and any subsequent ones. Oy!
*
*/
与:
/*
* Flush the buffer... or buff the flusher?
*
* In order to permit views to be nested within
* other views, we need to flush the content back out whenever
* we are beyond the first level of output buffering so that
* it can be seen and included properly by the first included
* template and any subsequent ones. Oy!
*
*/
if (is_array($_ci_vars)){
foreach ($_ci_vars as $key12 => $value12) {
unset($this->_ci_cached_vars[$key12]);
}
}
这应该在使用完变量后从缓存中删除它们。
错误报告:http://bitbucket.org/ellislab/codeigniter/issue/189/code-igniter-views-remember-previous
【问题讨论】:
标签: variables codeigniter