(a) CodeIgniter source code Analysis of the index.php

Source: Internet
Author: User

<?PHP/**---------------------------------------------------------------* Application Environment *------------------ ---------------------------------------------* * *//Configure the environment in which the project runs, which affects the display of error reports and the reading of the configuration files. */ Define(' Environment ', ' development ');/**---------------------------------------------------------------* ERROR REPORTING *-------------------------- ------------------------------------- * */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 FOLDER NAME *------------------------ ---------------------------------------* * * Set the system directory*/ $system _path= ' System ';/**---------------------------------------------------------------* application FOLDER NAME *------------------- --------------------------------------------* * * Set app directory*/ $application _folder= ' Application ';/**--------------------------------------------------------------------* DEFAULT CONTROLLER *------------------ -------------------------------------------------- * * */  //The $routing set in the following place will have a redirection effect on the route. See: core/codeiginter.php//$routing [' directory '] = '; $routing [' controller '] = '; $routing [' function '] = ';/**-------------------------------------------------------------------* CUSTOM CONFIG VALUES *------------------ ------------------------------------------------* Here is a place to define configuration information. In fact, in index.php many places can be set up some configuration, like just above the $routing, * and here Set the configuration information to take precedence over the configuration information set in the config/directory. */ //$assign _to_config[' name_of_config_item '] = ' value of config item ';//-------------------------------------------  -------------------------//END of USER configurable SETTINGS. Don't EDIT BELOW this line//--------------------------------------------------------------------/**---------------------------------------------------------------* Resolve The system path for increased Reliabili Ty *---------------------------------------------------------------*/ //Please refer to this: http://blog.163.com/wu_guoqing/blog/static/196537018201272512616394/ if(defined(' STDIN ')) {  chdir(dirname(__file__)); }  //calculates the $system_path, the path where the core file resides. The $path in Realpath ($path) must be a path that exists.  if(Realpath($system _path) !==FALSE) {  $system _path=Realpath($system _path).‘ /‘; } //make sure to/end $system _path=RTrim($system _path, ‘/‘).‘ /‘; //determine if the directory is 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)); }/**-------------------------------------------------------------------* After configuring some file directory information above, define some constants according to these directories. * ------------------------------------------------------------------- */ //The file name of this portal file is currently index.php Define(' Self ',PathInfo(__file__,pathinfo_basename)); //file name extension Define(' EXT ', '. php '); //Unified with/For directory separators (default is/) under Windows Yes/or \,linux Define(' BasePath ',Str_replace("\\", "/",$system _path)); //the directory where the front-end controller resides. In CI is this entry file.  Define(' Fcpath ',Str_replace(Self, ",__file__)); //Obtain the directory name of the core file, as follows://trim (Bashpath, '/'): first to trim the Bashpath, remove the end of the '/'//successively through STRRCHR (XXX, '/'): The above-mentioned string, intercept the last one ' /' begins at the end of a substring. Finally trim (XXX, '/'), remove both ends of the '/', the essence here is to remove the left side of the '/'.  Define(' Sysdir ',Trim(STRRCHR(Trim(BasePath, '/'), '/'), '/')); //define the application file directory//First look at whether the directory you configured is relative to the current file, and if so, you can define it successfully.  if(Is_dir($application _folder)) {  Define(' APPPATH ',$application _folder.‘ /‘); } Else {  //if not, then determine whether the application directory exists relative to the core file directory. If not, then pull it down.   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.‘ /‘); }/**--------------------------------------------------------------------* LOAD the BOOTSTRAP FILE *--------------- ----------------------------------------------------- * */ //In essence, this front-end controller and portal file is just the environment and some constants that define the current project's operation, and the real macro-control is the following codeigniter.php. require_onceBasePath. ' Core/codeigniter.php ';/** Summarize what this file does: * First, set up the current project's operating environment, which is mainly error reporting settings, this is placed in the entire project to run the first place. * Second, the configuration of some directory information, these are certain developers can customize things. Then, depending on the configuration directory information, CI will define something that will be useful later as a constant *, why do you do this? Because in the future in many different places, such as CI in the various components will use the path-related information, where the unified calculation and definition, in the rear * to reference and modify. * Third, the introduction of codeigniter.php to work. * * Move to the core file directory (click:) core/codeigniter.php ...*/

Original address: http://blog.163.com/wu_guoqing/blog/static/196537018201281672320862/

(a) CodeIgniter source code Analysis of the 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.