Welcome Guest, Not a member yet? Register   Sign In
Declare variable in constructor
#1

[eluser]stef25[/eluser]
How can I declare a variable in the constructor of a controller so that this variable is available in the dozens of functions in this controller? I'm not interested in passing it through to a view or model.

Code:
//constructor
    function __construct()
    {
        parent::__construct();
        $this->load->helper('form');
        $this->load->helper('html');
        
                //none of the following work
        $global['uid'] = $this->session->userdata('id');
        $this->load->vars($global);

                $this->uid = $this->session->userdata('id');
  
                $uid = $this->session->userdata('id');
    }

Thanks.


Messages In This Thread
Declare variable in constructor - by El Forum - 03-24-2011, 01:52 PM
Declare variable in constructor - by El Forum - 03-24-2011, 03:30 PM
Declare variable in constructor - by El Forum - 03-24-2011, 04:46 PM
Declare variable in constructor - by El Forum - 04-03-2011, 11:50 PM
Declare variable in constructor - by El Forum - 04-04-2011, 01:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB