ThinkPHP3.1.3 source code analysis (2) runtime. php

Source: Internet
Author: User
1. Example code runtime. php consists of three main parts: 1. Define the system directory and project directory path settings. You can re-define all path constants in the entry file. All path constants must end with defined (CORE_PATH) ordefine (CORE_PATH, THINK_PATH.Lib ); system Core class library directory defined (EXTEND_PATH) ordefine (EXTEN

1. Example code runtime. php consists of three main parts: 1. Define the system directory and project directory // path settings. You can re-define all path constants in the entry file and define ed (CORE_PATH) at the end) or define (CORE_PATH, THINK_PATH.Lib/); // system core class library directory defined (EXTEND_PATH) or define (EXTEN

I. Sample Code

Runtime. php mainly consists of three parts,

1. Define the system directory and project directory

// You can redefine all path constants in the entry file. All PATH constants must be defined ('Core _ path') or define ('Core _ path', THINK_PATH. 'lib/'); // system core class library directory defined ('extend _ path') or define ('extend _ path', THINK_PATH. 'extend/'); // System Extension directory defined ('mode _ path') or define ('mode _ path', EXTEND_PATH. 'mode/'); // Mode extension directory // omit defined ('temp _ path') or define ('temp _ path', RUNTIME_PATH. 'temp/'); // The project cache directory defined ('data _ path') or define ('data _ path', RUNTIME_PATH. 'Data/'); // project Data directory defined ('cache _ path') or define ('cache _ path', RUNTIME_PATH. 'cache/'); // Cache directory of the Project template

2. Load the core class and basic function library (common. php)

// Load the basic system function library require THINK_PATH. 'Common/Common. php'; // read the list of core files $ list = array (CORE_PATH. 'Core/Think. class. php ', CORE_PATH. 'Core/ThinkException. class. php', // The Exception Handling class CORE_PATH. 'Core/Behavior. class. php ',); // load mode file list foreach ($ list as $ key => $ file) {if (is_file ($ file) require_cache ($ file );}

3. Create a project directory

If (! Is_dir (LIB_PATH) {// create the project directory structure build_app_dir ();}/* If the Runtime directory does not exist, recreate the Runtime directory */elseif (! Is_dir (CACHE_PATH) {// check the cache directory check_runtime ();} elseif (APP_DEBUG) {// switch the debug mode to delete the compilation cache if (is_file (RUNTIME_FILE )) unlink (RUNTIME_FILE );}


The last step is to call Think. class. php

Think: Start ();


Ii. Small programming details:

// To facilitate the import of third-party class libraries, set the Vendor directory to include_pathset_include_path (get_include_path (). PATH_SEPARATOR. VENDOR_PATH );
For example, some. class. php is in the/a/B/c/include directory.

Introduce the class file include '/a/B/c/include/some. class. php ';

If set_include_path ('/a/B/c/include') is defined ');

Just include 'some. class. 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.