CodeIgniter Forums
Don't understand inconsistency in passing vars to a view - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Don't understand inconsistency in passing vars to a view (/showthread.php?tid=2289)



Don't understand inconsistency in passing vars to a view - El Forum - 07-27-2007

[eluser]Rob Stefanussen[/eluser]
I've run into something in my CI application that has me stumped.

I should be able to do this

Code:
// controller
$data['text'] = 'Hello World!';
$this->load->view('test_view', $data);

// view
echo $text; // echoes 'Hello World!';

However, apparently I do something (no idea what yet) unwittingly, and suddenly everything is being shoved into a 'vars' variable! So now I have to change my code to this to work properly:

Code:
// controller
$data['text'] = 'Hello World!';
$this->load->view('test_view', $data);

// view
echo $vars['text']; // echoes 'Hello World!';

Thanks in advance for your help!


Don't understand inconsistency in passing vars to a view - El Forum - 07-27-2007

[eluser]Rick Jolly[/eluser]
Code:
// instead of this:
$data['text'] = Hello World!;
// try this:
$data['text'] = 'Hello World!';



Don't understand inconsistency in passing vars to a view - El Forum - 07-27-2007

[eluser]Rob Stefanussen[/eluser]
yeah ...sorry bout that typo using the code tags


Don't understand inconsistency in passing vars to a view - El Forum - 07-27-2007

[eluser]coolfactor[/eluser]
Are you using any custom/3rd-party libraries on your site?


Don't understand inconsistency in passing vars to a view - El Forum - 07-27-2007

[eluser]Rob Stefanussen[/eluser]
yes, but only something very basic that I coded myself, should not be interfering with that at all... (I think...)