CodeIgniter Framework-source code Analysis of the entry file index.php

Source: Internet
Author: User
Tags codeigniter

The portal file of the CodeIgniter framework is primarily a configuration development environment, defining directory constants, and loading CI core class core/codeigniter.php.

The source code analysis is as follows:

<?PHP//This file is an entry, and all the files in the later stages are to be executed here. /*-----------------------------------------------* System Environment Configuration Constants * Ability to configure error display levels *-------------------------------------- ---------* By default: * Development//Development environment reports ALL errors * testing//test environment does not report errors * production//production environment does not report errors*/    Define(' Environment ', ' development '); /** Different error display levels are opened according to environment constants*/    Switch(Environment) { Case' Development ':error_reporting(E_all);  Break;  Case' Testing ': Case' Production ':error_reporting(0);  Break; default:Exit(' app environment settings are wrong. ')); } /**---------------------http://i.cnblogs.com/?postid=3921349&update=1 * System file directory, can be customized *--------------------* By default, the "System" folder is in the same directory as the index.php file. * You can change this path, but the path must be the same as the location of your system files * * Do not need the trailing slash "/"; */     $system _path= ' System '; /**---------------------------------------------------------------* application directory *----------------------------------- ----------------------------* * This folder is where the program is placed, by default the "Application" folder, which can be renamed or relocated to any location on the server. * Details can be accessed: * http://codeigniter.com/user_guide/general/managing_apps.html * * Does not require the trailing slash "/"; * */     $application _folder= ' Application '; /**--------------------------------------------------------------------* This place has a set of user code, I do not know how to find out, I do not write a *------- ------------------------------------------------------------- */
/* *---------------------------------------------------------------* Troubleshoot routing problems with a reliable path *------------------------------ --------------------------------- */ //do you want to run from the command line? ———— correctly set command line (CLI) requests in the current directory if(defined(' STDIN ')){ chdir(dirname(__file__)); } if(Realpath($system _path) !==FALSE){ $system _path=Realpath($system _path).‘ /‘; } //Make sure that the last one is a slash "/"; $system _path=RTrim($system _path, ‘/‘).‘ /‘; //determine if the system directory exists if( !Is_dir($system _path)){ Exit("Your system directory is not set correctly. Please open the following file reset: ".PathInfo(__file__,pathinfo_basename)); } /**-------------------------------------------------------------------* Set path (directory) constants *--------------------------- ---------------------------------------- */ //gets the current file name, which defines the entry file name Define(' Self ',PathInfo(__file__,pathinfo_basename)); //php file extension
Using global constants is not recommended Define(' EXT ', '. php '); //System Catalog Constants Define(' BasePath ',Str_replace("\\", "/",$system _path)); //Front-end controller path constant, which is the directory of the portal file Define(' Fcpath ',Str_replace(Self, ",__file__)); //System Core Directory Name
Trim (basepath, '/') removes the "/' ———— trim () function from both ends of the string to remove whitespace characters and other pre-defined characters
The strrchr() function finds the last occurrence of a string in another string and returns all characters from that position to the end of the string
Define(' Sysdir ',Trim(STRRCHR(Trim(BasePath, '/'), '/'), '/')); //Defining application Directory Constants if(Is_dir($application _folder)){ Define(' APPPATH ',$application _folder.‘ /‘); }Else{ if( !Is_dir(BasePath.$application _folder.‘ /‘)){ Exit("Your application directory may not be set correctly.") Please open the following file settings: ".Self ); } Define(' APPPATH ', basepath.$application _folder.‘ /‘); } /**--------------------------------------------------------------------* Loading bootstrap file *------------------------------ -------------------------------------- */
Before you define the environment and define constants, start loading CI core files and start a true CI tour
require_onceBasePath. ' Core/codeigniter '.EXT;/*End of File index.php*//*Location :./index.php*/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.