Welcome Guest, Not a member yet? Register   Sign In
echo variables forwarded from controller to view
#1

[eluser]HooJee[/eluser]
Hi Guys

I am trying to echo some variables in my view which are passed from the controller but I keep getting thefollowing error:

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined variable: arrData

Filename: admin/projects.php

Line Number: 59

This is the controller source code:
Code:
$arrData = array(
    'title'        => $title,
    'version'  => $version,
);
this->load->view('admin/reports', $arrData);

This is how I echo in the view:
Code:
<?php echo arrData['title']; ?>
#2

[eluser]rdjs[/eluser]
should it be $arrData['title']; ?
#3

[eluser]Dam1an[/eluser]
you just access, the variables inside the array, such as $title, $version etc
#4

[eluser]Kristof[/eluser]
you have to use the names you give within the array so $title, $version etc etc.
Basically CI just makes a variable of all info within an array so that way you can "transport" a lot of info.

hope this helps

a fellow CI starter
#5

[eluser]Adam Griffiths[/eluser]
Yeah you don't reference the variable by the array, simple the array index.

This happens on line 651 of the Loader class (system/libraries/Loader.php) — where the extract() function is used.




Theme © iAndrew 2016 - Forum software by © MyBB