CodeIgniter 核心代码阅读-入口文件index.php

index.php----唯一入口文件

<?php


//定义程序运行环境,可选项:development、testing、production
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';


//当一CLI方式运行程序时,设置当前目录
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));
}

//定义系统路径常量

//当前文件的名称,即index.php,即入口文件名称
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));

//php文件后缀
//此全局常量已经被弃用
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';




你可能感兴趣的:(CodeIgniter 核心代码阅读-入口文件index.php)