標籤:style blog http ar io color os sp on
1 <?php 2 3 /* 設定環境 */ 4 define(‘ENVIRONMENT‘, ‘development‘); 5 6 if (defined(‘ENVIRONMENT‘)) 7 { 8 switch (ENVIRONMENT) 9 {10 case ‘development‘:11 error_reporting(E_ALL);12 break;13 14 case ‘testing‘:15 case ‘production‘:16 error_reporting(0);17 break;18 19 default:20 exit(‘The application environment is not set correctly.‘);21 }22 }23 24 /* 系統檔案夾名 */25 $system_path = ‘system‘;26 27 /* 應用檔案夾名 */28 $application_folder = ‘application‘;29 30 // 把當前的目錄改變為指定的目錄31 if (defined(‘STDIN‘))32 {33 chdir(dirname(__FILE__));34 }35 36 if (realpath($system_path) !== FALSE) //返回絕對路徑37 {38 $system_path = realpath($system_path).‘/‘;39 }40 41 // 系統路徑42 $system_path = rtrim($system_path, ‘/‘).‘/‘;43 44 45 if ( ! is_dir($system_path))46 {47 exit("系統檔案路徑設定錯誤");48 }49 //當前檔案的名字50 define(‘SELF‘, pathinfo(__FILE__, PATHINFO_BASENAME));51 52 //副檔名53 define(‘EXT‘, ‘.php‘);54 55 // Path to the system folder56 define(‘BASEPATH‘, str_replace("\\", "/", $system_path));57 58 // Path to the front controller (this file)59 define(‘FCPATH‘, str_replace(SELF, ‘‘, __FILE__));60 61 // Name of the "system folder"62 define(‘SYSDIR‘, trim(strrchr(trim(BASEPATH, ‘/‘), ‘/‘), ‘/‘));63 64 // The path to the "application" folder65 if (is_dir($application_folder))66 {67 define(‘APPPATH‘, $application_folder.‘/‘);68 }69 else70 {71 if ( ! is_dir(BASEPATH.$application_folder.‘/‘))72 {73 exit("應用檔案夾設定錯誤");74 }75 76 define(‘APPPATH‘, BASEPATH.$application_folder.‘/‘);77 }78 79 /*80 * --------------------------------------------------------------------81 * LOAD THE BOOTSTRAP FILE82 * --------------------------------------------------------------------83 *84 * And away we go...85 *86 */87 require_once BASEPATH.‘core/CodeIgniter.php‘;88 89 /* End of file index.php */90 /* Location: ./index.php */View Code
該檔案主要是設定項目運行環境
設定系統系統目錄
設定部分常量:SELF、EXT、BASEPATH...
CodeIgniter源碼分析(二) 入口檔案index.php