CI框架只有一个入口文件就是index.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';//设定CI核心代码的文件夹

$application_folder = 'application';//设定自己应用所在的文件夹

  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));//当前文件的名字 index.php

    define('EXT', '.php');

    define('BASEPATH', str_replace("\\", "/", $system_path));//system文件夹的绝对地址

    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';//包含核心代码

 

 

 

posted on 2013-03-28 14:59  魅影_魍魉  阅读(339)  评论(0编辑  收藏  举报