CodeIgniter Forums
Where is this member variable of CI_Controller declared - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Where is this member variable of CI_Controller declared (/showthread.php?tid=43043)



Where is this member variable of CI_Controller declared - El Forum - 06-28-2011

[eluser]Crusoe[/eluser]
Code:
class Welcome extends CI_Controller {
    public function index()    {
        $this->load->view('welcome_message');
    }
}

If we are able to call $this->load->view successfully either the class Welcome or it's parent CI_Controller should have a member variable called load. I looked for it in the class definition.
Code:
class CI_Controller {
    private static $instance;
    public function __construct(){
        self::$instance =& $this;
        foreach (is_loaded() as $var => $class) {
            $this->$var =& load_class($class);
        }

        $this->load =& load_class('Loader', 'core');
        $this->load->_base_classes =& is_loaded();
        $this->load->_ci_autoloader();
        log_message('debug', "Controller Class Initialized");
     }

    public static function &get;_instance(){
        return self::$instance;
    }
}

It does not have a member variable called load. So, where did load come from ?


Where is this member variable of CI_Controller declared - El Forum - 06-28-2011

[eluser]wiredesignz[/eluser]
Code:
$this->load =& load_class('Loader', 'core');



Where is this member variable of CI_Controller declared - El Forum - 06-28-2011

[eluser]InsiteFX[/eluser]
Did you look at the CI Loader Class?

InsiteFX


Where is this member variable of CI_Controller declared - El Forum - 06-28-2011

[eluser]Crusoe[/eluser]
OK, I guessed as much. But, why not simply declare the instance variables in the base class ? Any specific reason for doing it this way ? BTW, how does one find out what are the members and methods of CI_Controller and CI_Model ? Is it listed somewhere in the documentation ?