【发布时间】:2013-08-12 23:00:42
【问题描述】:
这两种包含外部脚本的不同方式在性能上是否存在差异?
不使用变量:
include $_SERVER['DOCUMENT_ROOT'].'/class/conf.php';
include $_SERVER['DOCUMENT_ROOT'].'/class/Db.php';
include $_SERVER['DOCUMENT_ROOT'].'/class/Posts.php';
使用变量:
$path = $_SERVER['DOCUMENT_ROOT'];
include $path.'/class/conf.php';
include $path.'/class/Db.php';
include $path.'/class/Posts.php';
出于记忆目的,我尽可能避免使用变量,但我不知道这是否是提高性能的好习惯。
【问题讨论】:
-
是一个单一的变量会损害性能,考虑到优化吗?更好的可读性在这里不是更重要吗?