CI框架学习之一 (入口文件解析)

来源:互联网 发布:windows 获取窗口大小 编辑:程序博客网 时间:2024/06/11 09:26
<?php//定义开发环境 及 及报错级别define('ENVIRONMENT', 'development');       ######################################改动之一 是否为开发环境if (defined('ENVIRONMENT')){switch (ENVIRONMENT){case 'development':error_reporting(E_ALL);  //开发环境break;case 'testing':case 'production':error_reporting(0);      //生产环境break;default:exit('The application environment is not set correctly.');}}/* * 设置系统文件路径 这个路径可以共用 */$system_path = './system';               ######################################改动之二 自定义系统路径/* * 设置应用路径*/$application_folder = 'application';     ######################################改动之三 自定义应用路径/* * -------------------------------------------------------------------- * 设置默认的控制器 * -------------------------------------------------------------------- * * 默认情况下你会设置默认的控制器在 routes.php 文件里. * 在强制为一个应用硬编码 controller class/function 在这里.  大多数应用而言 * 不要设置路由在这里 * */// 默认控制器所在磁盘路径// $routing['directory'] = '';// 默认控制器.  例如:  Mycontroller// $routing['controller'] = '';// 这个控制器函数将被调用.// $routing['function']= '';/* * ------------------------------------------------------------------- *  定制配置项 * ------------------------------------------------------------------- * 它允许你设置自定义的 config * 项目去覆盖默认的 config 值 在 config.php 文件中. *  */// $assign_to_config['name_of_config_item'] = 'value of config item';// --------------------------------------------------------------------// 用户配置部分结束,这条线下面不要轻易改动// --------------------------------------------------------------------/* * --------------------------------------------------------------- *  解决系统路径平稳升级 * --------------------------------------------------------------- */// 设置当前磁的正确路径if (defined('STDIN')){chdir(dirname(__FILE__));}if (realpath($system_path) !== FALSE){$system_path = realpath($system_path).'/';}// 确保路径右边有一个正斜线$system_path = rtrim($system_path, '/').'/';// 验证系统路径的正确性if ( ! is_dir($system_path)){exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));}/* * ------------------------------------------------------------------- *  知道相关路径后,设置主要的文件包含内容 * ------------------------------------------------------------------- */// 当前文件的名字define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));// 文件扩展define('EXT', '.php');// 系统路径的定义define('BASEPATH', str_replace("\\", "/", $system_path));// 当前文件的控制器define('FCPATH', str_replace(SELF, '', __FILE__));// 系统路径define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));// 应用路径if (is_dir($application_folder)){define('APPPATH', $application_folder.'/');}else{if ( ! is_dir(BASEPATH.$application_folder.'/')){exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);}define('APPPATH', BASEPATH.$application_folder.'/');}/* * -------------------------------------------------------------------- * 加载引导文件 * -------------------------------------------------------------------- */require_once BASEPATH.'core/CodeIgniter.php';         ######################################改动之四 自定义引导文件(如果有)/* End of file index.php *//* Location: ./index.php */





1 0
原创粉丝点击