选择语言 :

 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
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
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;
}