Welcome Guest, Not a member yet? Register   Sign In
Don't understand inconsistency in passing vars to a view
#1

[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!
#2

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

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

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

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




Theme © iAndrew 2016 - Forum software by © MyBB