PHP include vs include_once(速度) [英] PHP include vs include_once (speed)
问题描述
可能重复:
为什么require_once不好用?
Possible Duplicate:
Why is require_once so bad to use?
我在某处读到,PHP中的include_once
和require_once
语句比它们的非一次性语句慢.这是一个显着的放缓吗?是否对此进行了任何测试或研究,并且在最新版本的PHP中进行了更改?
I've read somewhere that the include_once
and require_once
statements in PHP were slower than their non-once counterparts. Is this a significant slowdown? Has there been any testing or studies of this, and has it changed in recent versions of PHP?
推荐答案
速度提高极小,并且进行了参考检查以防止代码重复. 一次"附件是对同一代码被执行/包含两次的预防措施.执行此检查的代价是较小的代价.
The speed increase is minimal and comes as a reference check is conducted to prevent code duplication. The 'once' appendage is a preventative measure against the same code being executed/included twice..this performing this check comes at a minor speed cost.
如果曾经有一个实例在使用_once
,请查看为什么是这种情况,您是否真的以最有效的方式构建了代码?通常最好是不再需要依赖_once
并产生更好的代码(说起来容易做起来难!).
If there is ever an instance where you are using _once
look into why it is the case, is you code really built in the most efficient way? It is often better to remove the need to rely on _once
and produce better code (easier said than done!).
请参阅:
http://forums.digitalpoint.com/showthread.php?t=1693837
http://www.phpbb.com/community/viewtopic.php?f = 71& t = 565933
http://www.sitepoint.com/forums/showthread.php? t = 269085
http://www.quora.com/What-is-the-difference-between-functions-include-and-include_once-in-PHP
这篇关于PHP include vs include_once(速度)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!