Two. wp-blog-header.php file Analysis (i)
in the previous chapter we know that the index file only makes a declaration confirming the loaded constants, and then contains the Wp-blog-header file
wp-blog-header.php All content
by the above code we can divide the wp-blog-header.php into three parts.
1. Load the wp-load.php file in the current directory
2. Call WP () function
3. Load the template-loder.php file in the Wp-include directory
We step into the analysis, starting with wp-load.php, this file is very simple, come up to set the root directory and Error reporting method, and then contains wp-config.php this file.
Define (' Abspath ', DirName (__file__). '/' ); The root directory of WordPress///See the root directory of the wp-config.php file exists no, in the inclusion, no longer will be removed from the root of the constant "/" and re-included, and can not be found to enter the installation page. if (File_exists (Abspath. ' wp-config.php ') { require_once (abspath). ' wp-config.php ');} ElseIf (File_exists (DirName (Abspath). '/wp-config.php ') &&! File_exists (DirName (Abspath). '/wp-settings.php ') { require_once (dirname (Abspath)). '/wp-config.php ');} else { //install code, because do not study the installation, temporarily do not write}
we have installed WordPress here by default, So the program should be successfully loaded wp-config.php This file, this file is the database configuration information and identity key, then there is the AH and loaded the Wp-include directory under the wp-setting.php file.
Database information and Identity key is skipped//See, clearly in the wp-load.php file defines the root directory constants, here because to load wp-settings.php and made a second judgment to ensure that accidents occur, we have to learn this rigorous programming habits. if (!defined (' Abspath ')) define (' Abspath ', DirName (__file__). '/');/** set the WordPress variable and the include file. */require_once (Abspath. ' wp-settings.php ');