php CodeIgniter 路径常量定义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13992074/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 06:24:21  来源:igfitidea点击:

CodeIgniter path constants definitions

phpcodeigniter

提问by lomse

I have come across this page

我遇到过这个页面

https://www.codeigniter.com/user_guide/general/reserved_names.html

Could someone please explain to me what following constants do:

有人可以向我解释以下常量的作用:

EXT
FCPATH
SELF
BASEPATH
APPPATH

Thanks

谢谢

回答by swatkins

These constants are each defined in the index.phppage:

这些常量都在index.php页面中定义:

/*
 * -------------------------------------------------------------------
 *  Now that we know the path, set the main path constants
 * -------------------------------------------------------------------
 */
    // The name of THIS file
    define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));

    // The PHP file extension
    // this global constant is deprecated.
    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("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.'/');
    }

Starting at line 196 on https://github.com/EllisLab/CodeIgniter/blob/develop/index.php

https://github.com/EllisLab/CodeIgniter/blob/develop/index.php上的第 196 行开始

回答by SubRed

You can find its short definition in index.php on the root of your CI folder.

您可以在 CI 文件夹根目录的 index.php 中找到它的简短定义。

EXT: The PHP file extension
FCPATH: Path to the front controller (this file) (root of CI)
SELF: The name of THIS file (index.php)
BASEPATH: Path to the system folder
APPPATH: The path to the "application" folder

回答by Mohammad Khalik Shaikh

SELF= index.php

= index.php

Use when you want to include something from your root folder
FCPATH= C:\xampp\htdocs\your_root_folder\

当您想要包含根文件夹中的某些内容时使用
FCPATH= C:\xampp\htdocs\your_root_folder\

Use when you want to include something from your application folder
APPPATH= C:\xampp\htdocs\your_root_folder\application\

当您想包含应用程序文件夹中的某些内容时使用
APPPATH= C:\xampp\htdocs\your_root_folder\application\

BASEPATH= C:\xampp\htdocs\your_root_folder\system\

BASEPATH= C:\xampp\htdocs\your_root_folder\system\