标签: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 folder 56 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" folder 65 if (is_dir($application_folder)) 66 { 67 define(‘APPPATH‘, $application_folder.‘/‘); 68 } 69 else 70 { 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 FILE 82 * -------------------------------------------------------------------- 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 */
该文件主要是设置项目运行环境
设置系统系统目录
设置部分常量:SELF、EXT、BASEPATH...
CodeIgniter源码分析(二) 入口文件index.php
标签:style blog http ar io color os sp on
原文地址:http://www.cnblogs.com/crazelee/p/4167762.html