Welcome Guest, Not a member yet? Register   Sign In
__construct passing data?
#2

(This post was last modified: 12-24-2014, 12:54 PM by includebeer.)

$data is a local variable of your constructor. You need to make a member variable of your controller class if you want to use it somewhere else in other functions of your controller.

PHP Code:
class Staff extends MY_Controller {

 
   private $data;

 
   public function __construct()
 
   {
 
       parent::__construct();
 
       $this->load->model('staff_model');
 
       $this->data['session'] = $this->get_session_information();
 
   }

 
   public function index()
 
   {
 
       $this->load->view('hello'$this->data);
 
   
Reply


Messages In This Thread
__construct passing data? - by MoFish - 12-24-2014, 11:03 AM
RE: __construct passing data? - by includebeer - 12-24-2014, 12:53 PM



Theme © iAndrew 2016 - Forum software by © MyBB