codeigniter passing data to inner include php |
Dear all,
I am using codeigniter to develop php web site. Now I have the question. In controller, $this->load->view('index', $data); I want $data can also share in header.php and footer.php that included in index.php. It seems they cannot share and show undefined variables in header.php and footer.php. How to do???
In your controller you need to include the $data.
Use array $data and include it into your header and footer. $data = array(); $this->load->view('header', $data); $this->load->view('footer', $data);
Or do it this way, make $data global to all views.
PHP Code: $data = array(); What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Where would i add this code? I don't want to have to repeat all the data in every controller functions.
Code: class MY_Controller extends CI_Controller |
Welcome Guest, Not a member yet? Register Sign In |