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 ';