本文共 7354 字,大约阅读时间需要 24 分钟。
1 <?php 2 3 /* 4 *--------------------------------------------------------------- 5 * APPLICATION ENVIRONMENT 6 *--------------------------------------------------------------- 7 * 8 * You can load different configurations depending on your 9 * current environment. Setting the environment also influences 10 * things like logging and error reporting. 11 * 12 * This can be set to anything, but default usage is: 13 * 14 * development 15 * testing 16 * production 17 * 18 * NOTE: If you change these, also change the error_reporting() code below 19 * 20 */ 21 define ('ENVIRONMENT', 'development'); // 开发环境 22 /* 23 *--------------------------------------------------------------- 24 * ERROR REPORTING 25 *--------------------------------------------------------------- 26 * 27 * Different environments will require different levels of error reporting. 28 * By default development will show errors but testing and live will hide them. 29 */ 30 // 不同环境的 错误提示级别 31 if ( defined ('ENVIRONMENT')) 32 { 33 switch (ENVIRONMENT) 34 { 35 case 'development': 36 error_reporting ( E_ALL ); 37 break ; 38 39 case 'testing': 40 case 'production': 41 error_reporting (0); 42 break ; 43 44 default : 45 exit ('The application environment is not set correctly.'); 46 } 47 } 48 49 /* 50 *--------------------------------------------------------------- 51 * SYSTEM FOLDER NAME 52 *--------------------------------------------------------------- 53 * 54 * This variable must contain the name of your "system" folder. 55 * Include the path if the folder is not in the same directory 56 * as this file. 57 * 系统目录 58 */ 59 $system_path = 'system'; 60 61 /* 62 *--------------------------------------------------------------- 63 * APPLICATION FOLDER NAME 64 *--------------------------------------------------------------- 65 * 66 * If you want this front controller to use a different "application" 67 * folder then the default one you can set its name here. The folder 68 * can also be renamed or relocated anywhere on your server. If 69 * you do, use a full server path. For more info please see the user guide: 70 * http://codeigniter.com/user_guide/general/managing_apps.html 71 * 72 * NO TRAILING SLASH! 73 *应用目录 74 */ 75 $application_folder = 'application'; // 应用程序目录 76 77 /* 78 * -------------------------------------------------------------------- 79 * DEFAULT CONTROLLER 80 * -------------------------------------------------------------------- 81 * 82 * Normally you will set your default controller in the routes.php file. 83 * You can, however, force a custom routing by hard-coding a 84 * specific controller class/function here. For most applications, you 85 * WILL NOT set your routing here, but it's an option for those 86 * special instances where you might want to override the standard 87 * routing in a specific front controller that shares a common CI installation. 88 * 89 * IMPORTANT: If you set the routing here, NO OTHER controller will be 90 * callable. In essence, this preference limits your application to ONE 91 * specific controller. Leave the function name blank if you need 92 * to call functions dynamically via the URI. 93 * 94 * Un-comment the $routing array below to use this feature 95 * 96 */ 97 // The directory name, relative to the "controllers" folder. Leave blank 98 // if your controller is not in a sub-folder within the "controllers" folder 99 // $routing['directory'] = ''; 100 101 // The controller class file name. Example: Mycontroller 102 // $routing['controller'] = ''; 103 104 // The controller function you wish to be called. 105 // $routing['function'] = ''; 106 107 108 /* 109 * ------------------------------------------------------------------- 110 * CUSTOM CONFIG VALUES 111 * ------------------------------------------------------------------- 112 * 113 * The $assign_to_config array below will be passed dynamically to the 114 * config class when initialized. This allows you to set custom config 115 * items or override any default config values found in the config.php file. 116 * This can be handy as it permits you to share one application between 117 * multiple front controller files, with each file containing different 118 * config values. 119 * 120 * Un-comment the $assign_to_config array below to use this feature 121 * 122 */ 123 // $assign_to_config['name_of_config_item'] = 'value of config item'; 124 125 126 127 // -------------------------------------------------------------------- 128 // END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE 129 // -------------------------------------------------------------------- 130 131 /* 132 * --------------------------------------------------------------- 133 * Resolve the system path for increased reliability 134 * --------------------------------------------------------------- 135 */ 136 137 // Set the current directory correctly for CLI requests CLI,命令行界面 138 if ( defined ('STDIN')) 139 { 140 chdir ( dirname ( __FILE__ )); 141 } 142 // $system_path,即核心文件所在的路径。realpath($path)中的$path必须为存在的路径 143 if ( realpath ( $system_path ) !== FALSE ) // realpath返回规范化的绝对路径名 144 145 { 146 $system_path = realpath ( $system_path ).'/'; 147 } 148 149 // ensure there's a trailing slash 确保最后有个斜线 150 $system_path = rtrim ( $system_path , '/').'/'; 151 152 // Is the system path correct? 153 if ( ! is_dir ( $system_path )) 154 { 155 exit ("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ". pathinfo ( __FILE__ , PATHINFO_BASENAME)); 156 } 157 158 /* 159 * ------------------------------------------------------------------- 160 * Now that we know the path, set the main path constants 161 * ------------------------------------------------------------------- 162 */ 163 // 这个入口文件的文件名,目前是index.php 164 // The name of THIS file 165 define ('SELF', pathinfo ( __FILE__ , PATHINFO_BASENAME)); // index.php 166 167 // The PHP file extension 168 // this global constant is deprecated. 169 define ('EXT', '.php'); 170 171 // Path to the system folder// 统一以/为目录分隔符(windows下是/或\,linux下默认是/) 172 define ('BASEPATH', str_replace ("\\", "/", $system_path )); // F:/products/zh.ci/system/ 173 174 // Path to the front controller (this file) 175 define ('FCPATH', str_replace (SELF, '', __FILE__ )); // F:\products\zh.ci\ 176 177 // Name of the "system folder"核心文件的目录名 178 define ('SYSDIR', trim ( strrchr ( trim (BASEPATH, '/'), '/'), '/')); // strrchr — 查找指定字符在字符串中的最后一次出现 system 179 180 // The path to the "application" folder 181 if ( is_dir ( $application_folder )) // 如果文件名存在并且为目录则返回 TRUE。如果 filename 是一个相对路径,则按照当前工作目录检查其相对路径。 182 { 183 define ('APPPATH', $application_folder .'/'); 184 } 185 else 186 { 187 if ( ! is_dir (BASEPATH. $application_folder .'/')) 188 { 189 exit ("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF); 190 } 191 192 define ('APPPATH', BASEPATH. $application_folder .'/'); 193 } 194 /* 195 * -------------------------------------------------------------------- 196 * LOAD THE BOOTSTRAP FILE 197 * -------------------------------------------------------------------- 198 * 199 * And away we go... 200 * 201 */ 202 // echo BASEPATH; 203 require_once BASEPATH.'core/CodeIgniter.php'; 204 205 /* End of file index.php */ 206 /* Location: ./index.php */ 转载于:https://my.oschina.net/20130614/blog/118929