简明现代魔法 -> WordPress -> WP 代码分析:index.php
WP 代码分析:index.php
2010-03-11
本系列中 WordPress 的版本为 wordpress-2.9.2-zh_CN。
WordPress 的 index.php 很简洁:
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
* 这是 WordPress 应用的开始,这个文件不会做其它复杂的事情,它仅仅加载 wp-blog-header.php
* wp-blog-header.php 只是让 WordPress 去加载主题
* @package WordPress
*/
/**
* 让 WordPress 加载 WordPress 主题,并且输出该主题
* @var bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template
* 加载 WordPress 环境和模板
*/
require('./wp-blog-header.php');
?>
在PHP中,使用函数define()来定义常量。其语法如下:
bool define (string name, mixed value [, bool case_insensitive] );
说明:define函数有3个参数,第一个参数为常量名称,即标志符,第二个参数为常量的值,第三个参数指定是否大小写敏感,设定为True,表示不敏感。
所以
define('WP_USE_THEMES', true);
这一行代码是说,常量 WP_USE_THEMES 大小写不敏感。
接下来的是
require('./wp-blog-header.php');
那么让我们在下一篇文章中分析下 wp-blog-header.php 吧。
