您的位置:首页 > 编程语言 > PHP开发

php两种include加载文件方式效率比较

2013-06-19 13:35 525 查看
继续完善“X计划”的核心部分,核心嘛,就要加载必须的文件,尝试了两种方法,发现效率是不同的,分享一下吧~ 先来说说两种方式:

1)定义一个字符串变量,里面保存要加载的文件列表。然后foreach加载。 $a = '/a.class.php;/Util/b.class.php;/Util/c.class.php'; $b = '/d.php;/e.class.php;/f.class.php;/g.class.php';

// 加载基本系统文件 $kernel_require_files = explode(';', $a);//SYS_REQUIRE_LIB_FILE_LIST); foreach($kernel_require_files as $f){ require_once(SYS_LIB_PATH.'/System'.$f); }

// 加载基本系统文件 $kernel_require_files = explode(';', $b);//SYS_BASE_FILE_LIST); foreach($kernel_require_files as $f){ require_once(KERNEL_PATH.$f); }

2)把所有的要加载的文件都在一个include文件里面加载,当前页直接include这个include文件。 include.php文件内容 require_once('func.php'); require_once('LangManager.class.php'); require_once('_KernelAutoLoader.class.php'); require_once('ApplicationSettingManager.class.php');

require_once('lib/System/Activator.class.php'); require_once('lib/System/Util/CXML.class.php'); require_once('lib/System/Util/CWeb.class.php');
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: