• 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
__construct passing data?


I'm trying to do a 'get' query inside the __construct of my controller to get some users information. I have a general 'core' layout which needs this information.  When trying to do a print_r($data) inside my core view, it returns blank. Could someone point out what im doing wrong?

PHP Code:
class Staff extends MY_Controller {
   public function __construct()
       $data['session'] = $this->get_session_information();
       print_r($data['session']); // this returns my data as expected

However when in my view.... nothing is returned. I'm assuming it is because $data is not passed into the view at this point in the construct. I dont want it to pass the view at this stage. I therfore think that data needs to somehow be made public, so it can be built up inside the controller at any stage. Could someone clarify what i'm doing incorrectly?

PHP Code:
php  print_r($session); ?>
<?php  print_r
($data); ?>



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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.