PHP/CodeIgniter - Setting variables in __construct(), but they're not accessible from other functions
问题 I'm happy a bit of a variable scoping problem. Maybe I just need more coffee... Here's my (simplified) code - this is in CodeIgniter 2: class Agent extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('agent_model'); // Get preliminary data that will be often-used in Agent functions $user = $this->my_auth_library->get_user(); $agent = $this->agent_model->get_agent($user->id); } public function index() { $this->template->set('info', $this->agent