我试图了解CodeIgniter中的框架结构,我刚刚开始并想出了这个小小的误解.
那么有人可以帮助我站在下面: -
1-为什么他们使用引用传递类的实例...我的意思是为什么不只是一个简单的变量?
2-为什么函数将类的名称存储在数组而不是"字符串变量"(请不要判断我的php术语是最糟糕的)...?!
static $_classes = array();
^^^^^^^ this cloud be just ("") or am i missing something
Run Code Online (Sandbox Code Playgroud)
这是功能,所以你不会去寻找它.
function &load_class($class, $directory = 'libraries', $prefix = 'CI_')
{
static $_classes = array();
// Does the class exist? If so, we're done...
if (isset($_classes[$class]))
{
return $_classes[$class];
}
$name = FALSE;
// Look for the class first in the local application/libraries folder
// then in the native system/libraries folder
foreach (array(APPPATH, BASEPATH) as $path)
{
if (file_exists($path.$directory.'/'.$class.'.php'))
{
$name …Run Code Online (Sandbox Code Playgroud)