CI 入口文件解析

<?php

/*
 *定义应用开发环境,如development,testing,production。会提供不同的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';
 
/**
 * 规范会路径,并判断是否存在,不存在则报错退出
 */
// PHP CLI方式运行
if (defined('STDIN'))
{
chdir(dirname(__FILE__));
}
 
if (realpath($system_path) !== FALSE)
{
$system_path = realpath($system_path).'/';
}
 
// ensure there's a trailing slash
$system_path = rtrim($system_path, '/').'/';
 
// Is the system path correct?
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));
 
//文件扩展名
define('EXT', '.php');
 
//系统目录常量: 统一以/为目录分隔符(windows可能会以\分割目录,所以要替换掉,注意转义)
define('BASEPATH', str_replace("\\", "/", $system_path));
//前端控制器路径常量,也就是默认入口文件的那个目录
define('FCPATH', str_replace(SELF, '', __FILE__));
// 系统核心目录名
        //这里分析下:trim(BASEPATH, '/')是去掉首尾的/
        //strrchr()是或最后一个/开始到结尾的字符串,默认是/system
        //最后再trim当然是去掉/了,默认就是system
define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
 
/**
         * 定义应用目录常量
         */
        //如果应用目录在当前目录直接定义常量成功了
if (is_dir($application_folder))
{
define('APPPATH', $application_folder.'/');
}
else
{
                //如果不是当前目录就判断配置的该目录相对于CI系统目录是否存在,不存在,你就完了,存在下面继续定义
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.'/');
}
 
/*
 *前面都是定义环境和定义常量,现在就加载CI核心文件了,真正开始CI之旅
 */
require_once BASEPATH.'core/CodeIgniter.php';
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值