Home > Article > Backend Development > PHP website example analysis_PHP tutorial
if(version_compare(PHP_VERSION,5.0.0,<) ) { //The version is less than 5.0.0
Die(ThinkPHP 1.* require_once PHP > 5.0 !); //Prompt and terminate
}
//Record start running time bkJia comment
$GLOBALS[_beginTime] = microtime(TRUE);
//Global variable TRUE means the addition of seconds and microseconds
//ThinkPHP system directory definition
if(!defined(THINK_PATH)) define(THINK_PATH, dirname(__FILE__));
//The value of THINK_PATH is: d:www_4000Think_path
//dirname(dirname(__FILE__)); What you get is the directory name above the file
//dirname(__FILE__); What you get is the directory name of the layer where the file is located
if(!defined(APP_NAME)) define(APP_NAME, md5(THINK_PATH));
//If there is no constant APP_NAME, encrypt the application name (bkJia Chinese website)
if(!defined(APP_PATH)) define(APP_PATH, dirname(THINK_PATH)./.APP_NAME);
if(!defined(RUNTIME_PATH)) define(RUNTIME_PATH,APP_PATH./Temp/);
//Runtime path
if(file_exists(RUNTIME_PATH.~runtime.php)) {
// If there is this file in the runtime path, load the framework core cache file
// If the core file has been modified, please delete the cache (bkJia.com)
require_once RUNTIME_PATH.~runtime.php;
}else{
//Load system definition file
require_once THINK_PATH."/Common/defines.php";
// System function library
require_once THINK_PATH."/Common/functions.php";
//Load the function files required for compilation
require_once THINK_PATH."/Common/runtime.php";
// Check the project directory structure during the first run and automatically create it if it does not exist
if(!file_exists(RUNTIME_PATH)) {
//Create project directory structure
buildAppDir();
}
//Load ThinkPHP base class
import("Think.Core.Base");
//Load exception handling class
import("Think.Exception.ThinkException");
//Load log class
Import("Think.Util.Log");
//Load Think core class
import("Think.Core.App");
import("Think.Core.Action");
import("Think.Core.Model");
import("Think.Core.View");
// Whether to generate core cache
$cache = ( !defined(CACHE_RUNTIME) || CACHE_RUNTIME == true );
if($cache) {
If(defined(STRIP_RUNTIME_SPACE) && STRIP_RUNTIME_SPACE == false ) {
$fun = file_get_contents;
}else{
$fun = php_strip_whitespace;
}
// Generate a cache of core files and remove file whitespace to reduce size
$content = $fun(THINK_PATH./Common/defines.php);
$content .= $fun(THINK_PATH./Common/functions.php);
$content .= $fun(THINK_PATH./Lib/Think/Core/Base.class.php);
$content .= $fun(THINK_PATH./Lib/Think/Exception/ThinkException.class.php);
$content .= $fun(THINK_PATH./Lib/Think/Util/Log.class.php);
$content .= $fun(THINK_PATH./Lib/Think/Core/App.class.php);
$content .= $fun(THINK_PATH./Lib/Think/Core/Action.class.php);
$content .= $fun(THINK_PATH./Lib/Think/Core/Model.class.php);
$content .= $fun(THINK_PATH./Lib/Think/Core/View.class.php);
}
If(version_compare(PHP_VERSION,5.2.0,<) ) {
//Load compatible function
require_once THINK_PATH./Common/compat.php;
if($cache) {
$content .= $fun(THINK_PATH./Common/compat.php);
}
}
if($cache) {
file_put_contents(RUNTIME_PATH.~runtime.php,$content);//Write string to file
unset($content);//Destroy $content
}
}
// Record loading file time
$GLOBALS[_loadTime] = microtime(TRUE);
?>