I have the following code in a Controller:
$data['what'] = 'test';
$this->load->view('test_view', $data);
$this->load->view('test_view');
View:
<?php
echo $what;
?>
The Result when running this code is:
testtest
Shouldn't it be simply 'test' because the second time I am not passing the variable $data? How can I make CodeIgniter behave this way?
EDIT1:
I have come up with a temporary workaround for this problem:
Replace in 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!
*
*/
With:
/*
* 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]);
}
}
That should remove the variables from the cache after they're done being used.
BUG REPORT: http://bitbucket.org/ellislab/codeigniter/issue/189/code-igniter-views-remember-previous