博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
初学CI源码
阅读量:7072 次
发布时间:2019-06-28

本文共 1598 字,大约阅读时间需要 5 分钟。

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

 

 

 

转载于:https://www.cnblogs.com/monsters/archive/2013/03/28/2986761.html

你可能感兴趣的文章
Django model :add a non-nullable field 'SKU' to product without a default; we can't do that
查看>>
20.SSM整合-全注解开发
查看>>
让我欲罢不能的node.js
查看>>
js--webSocket入门
查看>>
request:实现页面包含
查看>>
[置顶] ASP.NET环境的基本配置——VS2008+SQLEXPRESS+IIS5.1/IIS7.0
查看>>
冲刺阶段第八天
查看>>
SignalR指定用户推送消息
查看>>
PHP 数组模糊查询
查看>>
BGP协议
查看>>
关于同步、异步与阻塞、非阻塞的理解
查看>>
python2和python3的区别
查看>>
《DevExpress》记录之TreeList
查看>>
SpringCloud-Eureka服务注册与发现(二)
查看>>
网络字体原理
查看>>
观察者模式【java版】
查看>>
SpringMVC(十七)文件上传
查看>>
CI重定向:php(codeigniter)中如何重定向
查看>>
UItextView 设置为不可以复制粘贴
查看>>
线段树节点信息合并
查看>>