PHP Excellent framework CodeIgniter Learning Series--codeigniter.php Overview

Source: Internet
Author: User
Tags define definition codeigniter

Codeigniter.php is the core document of the CI framework. It runs after the front-end controller index.php, loads various base components, and executes the request. Once the file has been executed, the request is finished. Therefore, this article can only do a general explanation of the codeigniter.php, in the middle if there is an important part, will write a new log to explain in detail.

The notes for the CI framework are very detailed and prescriptive. The official explanation for this file is System initialization file (System initialization files), loading the base class library, and executing the request. It is different from index.php just setting up the environment and defining important paths, but going deep into the core of the framework.

Let's study the paper together.

defined Exit (' No Direct script access allowed ');

The first line of code, if no ' basepath ' is defined, exits, and the variable is defined in the index.php file. So the intent is obvious to prevent the file from being accessed directly . This line of code can be seen in many files in the CI framework.

  

1 Const ci_version = ' 3.1.7 ';

Define the version of the CI framework, and it is a global variable, and each framework has a similar definition, why not use the Define definition but use static variables, not very clear .

 /*   *-------------------------------------- ----------------* Load the Framework constants *------------------------------------------------------ */ if  (file_exists  (APPPATH. ') config/'. Environment. ' /constants.php '  require_once  (APPPATH .‘ config/'. Environment. '    /constants.php '  if  (file_exists  (APPPATH. ') config/constants.php '  require_once  (A Pppath. '    config/constants.php ' 

The constant that loads the frame. If the environment variables (product,development,test) folder exists, and there are constants.php files in the folder, load first. And the priority is higher than the post-load. The constants.php file defines some system-level constants (defined by define) that do not change, such as file-readable mode, exit status code, and so on. Specific can refer to constants.php study.

Here's a tip, many frameworks use defined to detect if they are defined before defining a constant, use file_exists for referenced files, and class_exists for class definitions. Prevent duplicate definitions.

1 /* 2  * ------------------------------------------------------ 3  *  Load the global functions4  *------------------------------------------------------5   */6     require_once(basepath. ') Core/common.php ');
View Code

Reference a commonly used function file. The functions in this file are the functions commonly used in the framework, as well as some of the core functions. Refer to common.php learning.

Security procedures

  For PHP with a version less than 5.4, set some variables in the global variable $globals array to null, stating that it is for security reasons. But I didn't find the origin of this security factor.

1     Set_error_handler (' _error_handler '); 2     Set_exception_handler (' _exception_handler '); 3     register_shutdown_function (' _shutdown_handler ');
View Code

Custom error handlers, exception handlers, PHP abort execution handlers. For a CI error and exception handling mechanism, see.

PHP Excellent Framework CodeIgniter Learning Series--codeigniter.php Overview

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.