Welcome Guest, Not a member yet? Register   Sign In
Where is this member variable of CI_Controller declared
#1

[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 ?
#2

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

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

InsiteFX
#4

[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 ?




Theme © iAndrew 2016 - Forum software by © MyBB