<?php if (!empty($assign_to_config['subclass_prefix'])) { // 这里的get_config是全局函数,主要用于新增或替换原有配置 get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix'])); }
加载composer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<?php if ($composer_autoload = config_item('composer_autoload')) { if ($composer_autoload === TRUE) { file_exists(APPPATH.'vendor/autoload.php') ? require_once(APPPATH.'vendor/autoload.php') : log_message('error', '$config[\'composer_autoload\'] is set to TRUE but '.APPPATH.'vendor/autoload.php was not found.'); } elseif (file_exists($composer_autoload)) { require_once($composer_autoload); } else { log_message('error', 'Could not find the specified $config[\'composer_autoload\'] path: '.$composer_autoload); } }
<?php /* * ------------------------------------------------------ * Instantiate the hooks class * ------------------------------------------------------ */ $EXT =& load_class('Hooks', 'core');
/* * ------------------------------------------------------ * Is there a "pre_system" hook? * ------------------------------------------------------ */ $EXT->call_hook('pre_system');
配置类->CFG
Config配置管理组件。主要用于加载配置文件、获取和设置配置项等
1 2 3 4 5 6 7 8 9 10 11 12
<?php $CFG =& load_class('Config', 'core');
// Do we have any manually set config items in the index.php file? // 上文提到过,在index.php入口文件中,配置项具有优先权,会替换替他文件内的配置 if (isset($assign_to_config) && is_array($assign_to_config)) { foreach ($assign_to_config as $key => $value) { $CFG->set_item($key, $value); } }
// 检查mbstring扩展项是否开启 if (extension_loaded('mbstring')) { define('MB_ENABLED', TRUE); // mbstring.internal_encoding is deprecated starting with PHP 5.6 // and it's usage triggers E_DEPRECATED messages. @ini_set('mbstring.internal_encoding', $charset); // This is required for mb_convert_encoding() to strip invalid characters. // That's utilized by CI_Utf8, but it's also done for consistency with iconv. mb_substitute_character('none'); } else { define('MB_ENABLED', FALSE); }
// 开启字符集转换扩展 // There's an ICONV_IMPL constant, but the PHP manual says that using // iconv's predefined constants is "strongly discouraged". if (extension_loaded('iconv')) { define('ICONV_ENABLED', TRUE); // iconv.internal_encoding is deprecated starting with PHP 5.6 // and it's usage triggers E_DEPRECATED messages. @ini_set('iconv.internal_encoding', $charset); } else { define('ICONV_ENABLED', FALSE); }
// 设置内部编码 if (is_php('5.6')) { ini_set('php.internal_encoding', $charset); }
// 针对404的处理 if ($e404) { if ( ! empty($RTR->routes['404_override'])) { if (sscanf($RTR->routes['404_override'], '%[^/]/%s', $error_class, $error_method) !== 2) { $error_method = 'index'; }
$error_class = ucfirst($error_class);
if ( ! class_exists($error_class, FALSE)) { if (file_exists(APPPATH.'controllers/'.$RTR->directory.$error_class.'.php')) { require_once(APPPATH.'controllers/'.$RTR->directory.$error_class.'.php'); $e404 = ! class_exists($error_class, FALSE); } // Were we in a directory? If so, check for a global override elseif ( ! empty($RTR->directory) && file_exists(APPPATH.'controllers/'.$error_class.'.php')) { require_once(APPPATH.'controllers/'.$error_class.'.php'); if (($e404 = ! class_exists($error_class, FALSE)) === FALSE) { $RTR->directory = ''; } } } else { $e404 = FALSE; } }
// Did we reset the $e404 flag? If so, set the rsegments, starting from index 1 if ( ! $e404) { $class = $error_class; $method = $error_method;
<?php if ($EXT->call_hook('display_override') === FALSE) { $OUT->_display(); }
/* * ------------------------------------------------------ * Is there a "post_system" hook? * ------------------------------------------------------ */ $EXT->call_hook('post_system');