leon
leon

Reputation: 1

CodeIgniter 3.1. Class Loader. Cannot understand the line $this->_ci_classes =& is_loaded();

I need some help with CodeIgniter framework 3.1. Class Loader.

I cannot understand the line $this->_ci_classes =& is_loaded(); The expression &is_loaded(); is correct?

class CI_Loader {

protected $_ci_classes =    array();
...

public function __construct()
{
    $this->_ci_classes =& is_loaded();

    ...
}

...
public function is_loaded($class)
{
    return array_search(ucfirst($class), $this->_ci_classes, TRUE);
}
...

...

Upvotes: 0

Views: 578

Answers (1)

Abdulla Nilam
Abdulla Nilam

Reputation: 38584

What is protected $_ci_classes??

just an variable which declared as protected, to use inside class. Read PHP: Public, Private, Protected. It can assign to array() or string as well.


What does by =& ??

It means assign the reference to Right hand side from Left hand side. Simply Left = Right. Read What does the PHP operator =& mean?

$a = 1000; # $a assign to 1000
$b =& $a; # $b has same value of $a(1000)

What array_search(ucfirst($class), $this->_ci_classes, TRUE) does ??

When ever you add libraries on autoload.php, for the our view it is an just a library. But inside CI its is an class which is defined on system folder. So when ever you load the library its allowed to use by this Load class. That's the function of CI_Loader Class

Read PHP array_search() Function

/**
 * Is Loaded
 *
 * A utility method to test if a class is in the self::$_ci_classes array.
 *
 * @used-by Mainly used by Form Helper function _get_validation_object().
 *
 * @param   string      $class  Class name to check for
 * @return  string|bool Class object name if loaded or FALSE
 */

Upvotes: 1

Related Questions