CodeIgniter Forums
[solved]$this->load->vars($array) question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: [solved]$this->load->vars($array) question (/showthread.php?tid=38585)



[solved]$this->load->vars($array) question - El Forum - 02-12-2011

[eluser]quasiperfect[/eluser]
hi

The variables loaded using $this->load->vars($array) are usable inside the controller ?
If so, how ?

I tried like this but no luck inside the view is ok but not in the controller
I'm using the latest reactor from bitbucket
Code:
class Welcome extends MY_Controller {
    function __construct()
    {
        parent::__construct();
        $myvars['b'] = 'test';
        $this->load->vars($myvars);
    }

    function index()
    {
        echo $b;
    }
}



[solved]$this->load->vars($array) question - El Forum - 02-12-2011

[eluser]WanWizard[/eluser]
No, the result of $this->load->vars() is only used in views.

The example is a bit pointless, if you want something like that, either use $this->b, or $this->myvars['b'] if you want to retain the array.


[solved]$this->load->vars($array) question - El Forum - 02-12-2011

[eluser]quasiperfect[/eluser]
thanks for responding
i always used $this->b but i wanted to be sure on the purpose of $this->load->vars()