您的位置:首页 > 编程语言 > PHP开发

CodeIgniter源码分析(二) 入口文件index.php

2014-12-16 18:15 711 查看
<?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';

/* 应用文件夹名 */
$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("系统文件路径设置错误");
}
//当前文件的名字
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));

//文件扩展名
define('EXT', '.php');

// Path to the system folder
define('BASEPATH', str_replace("\\", "/", $system_path));

// Path to the front controller (this file)
define('FCPATH', str_replace(SELF, '', __FILE__));

// Name of the "system folder"
define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));

// The path to the "application" folder
if (is_dir($application_folder))
{
define('APPPATH', $application_folder.'/');
}
else
{
if ( ! is_dir(BASEPATH.$application_folder.'/'))
{
exit("应用文件夹设置错误");
}

define('APPPATH', BASEPATH.$application_folder.'/');
}

/*
* --------------------------------------------------------------------
* LOAD THE BOOTSTRAP FILE
* --------------------------------------------------------------------
*
* And away we go...
*
*/
require_once BASEPATH.'core/CodeIgniter.php';

/* End of file index.php */
/* Location: ./index.php */


View Code
该文件主要是设置项目运行环境

设置系统系统目录

设置部分常量:SELF、EXT、BASEPATH...
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: