选择语言 :

 Bootstrap::import_library

导入指定类库 支持多个,当一次导入多个时,从数组最后一个开始导入

导入的格式必须是类似 com.a.b 的形式,否则会抛出异常,例如: com.myqee.test

 Bootstrap::import_library('com.myqee.test');
 Bootstrap::import_library(array('com.myqee.test','com.myqee.cms'));
num Bootstrap::import_library( string|array $library_name )

参数列表

参数 类型 描述 默认值
$library_name string|array 指定类库 支持多个
返回值
  • num 返回新加载的类库总数
File: ./core/bootstrap.php
public static function import_library($library_name)
{
    if (!$library_name)return false;

    $library_name = (array)$library_name;

    # 反向排序,从最后一个开始导入
    $library_name = array_reverse($library_name);

    $config_files = array();

    $load_num = 0;
    foreach ($library_name as $lib)
    {
        $set = self::_add_include_path_lib($lib);

        if (true===$set[2])
        {
            # 已加载过
            continue;
        }

        $config_file = $set[1] .'config'. EXT;

        if (is_file($config_file))
        {
            $config_files[] = $config_file;
        }

        $load_num++;

        if (IS_DEBUG && class_exists('Core', false) && class_exists('Debug', false))Core::debug()->info('import a new library: '.Core::debug_path($lib));
    }

    if ($config_files)
    {
        __include_config_file(self::$config, $config_files);
    }

    return $load_num;
}