We usually call a method using an object , but here in codeigniter a variable calls method. How did they design it ? and i came across something called super object,how did they make such an object.any help is appretiated.I would like to know how the inner architecture work here.
$this->load->view(); //it loads view , how come $this->load an object here
答案 0 :(得分:2)
Navigate to /system/core/Controller.php
, you can see below lines, where it all get triggers
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->initialize();
log_message('info', 'Controller Class Initialized');
}
Take look at this as well system/core/Loader.php
, you can see something like this (related ->view()
)
/**
* View Loader
*
* Loads "view" files.
*
* @param string $view View name
* @param array $vars An associative array of data
* to be extracted for use in the view
* @param bool $return Whether to return the view output
* or leave it to the Output class
* @return object|string
*/
public function view($view, $vars = array(), $return = FALSE)
{
return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_prepare_view_vars($vars), '_ci_return' => $return));
}