Question about $this->load->vars($array) |
[eluser]shinokada[/eluser]
I read the user guide about loader class. I understood most of them except, $this->load->vars($array. I came to a code like this and I don't really understand what's going on here. Code: function index() Could anyone explain about $this->load->vars($array) for me please? Thanks in advance.
[eluser]Colin Williams[/eluser]
That method takes the array you pass, extract()s it, making the data available to any and all views you load. For instance, these two pieces of code have basically the same effect: Code: $data = array('colors' => array('green', 'blue', 'red')); Code: $this->load->vars(array('colors' => array('green', 'blue', 'red'))); $this->load->vars() is especially useful when you have variables you want to use in all views (like maybe site name, username, is_logged_in, etc).
[eluser]Shiro[/eluser]
recently I had update my code from Code: $this->load->vars($data); to Code: $this->load->view($this->_container, $data); save a line space |
Welcome Guest, Not a member yet? Register Sign In |