Welcome Guest, Not a member yet? Register   Sign In
why still checking loaded files even though include a file using 'include_once'
#1

[eluser]noname11[/eluser]
Hey all! I have a problem about class Loader that why still checking loaded files even though include a file using 'include_once'. thanks very much

// Safety: Was the class already loaded by a previous call?
if (in_array($filepath, $this->_ci_loaded_files))
{
// Before we deem this to be a duplicate request, let's see
// if a custom object name is being supplied. If so, we'll
// return a new instance of the object
if ( ! is_null($object_name))
{
$CI =& get_instance();
if ( ! isset($CI->$object_name))
{
return $this->_ci_init_class($class, '', $params, $object_name);
}
}

$is_duplicate = TRUE;
log_message('debug', $class." class already loaded. Second attempt ignored.");
return;
}

include_once($filepath);
$this->_ci_loaded_files[] = $filepath;
return $this->_ci_init_class($class, '', $params, $object_name);
#2

[eluser]mddd[/eluser]
Because the class is not only loaded but also instantiated. It would give problems if the class instance was overwritten every time you loaded it again.
#3

[eluser]Georgi Budinov[/eluser]
Hmm btw this is actually interesting. I remember I ran through some tests on performance that turned out include/require _once have worse performance than require/include. The question is why it is include_once ?
#4

[eluser]noname11[/eluser]
anyhow,thanks! guys.




Theme © iAndrew 2016 - Forum software by © MyBB