(02-06-2017, 12:29 PM)polarthedog Wrote: The troubling part is the way it holds nested info.
What I find troubling is a situation where I might be repeatedly loading views and data loaded earlier sticks around:
PHP Code:
public function somemethod() {
$foo = array(
"val1" => "one",
"val2" => "two",
"val3" => "three"
);
$this->load->view("testview", $foo);
$bar = array(
"val1" => "changed one",
"val2" => "changed two"
);
$this->load->view("testview", $bar);
}
When I load the view the second time with $bar
--an entirely different data array-- then $val3 from $foo which was used the first time is defined. Here's a sample testview.php:
PHP Code:
<?php
/**
* view to test scope when loading views in CI
*/
?>
<div>val1=<?php echo $val1; ?></div>
<div>val2=<?php echo $val2; ?></div>
<div>val3=<?php echo $val3; ?></div>
And here's the output:
Code:
val1=one
val2=two
val3=three
val1=changed one
val2=changed two
val3=three
If I load a view and specify some entirely different data array, I would expect that only the keys in that array get expanded into vars within the view.