开发者

What is faster - using PEAR package or including required libraries directly into php code?

What will work faster - using PEAR package or require Some_Library.php files in code?

For example, what is faster - using Smarty as PEAR module or using require_once("Smarty.php")? Ha开发者_C百科ve anyone tested this?

Thank you


Both will be loaded from the include paths. The include path that comes first will be slighty faster, but I highly doubt you will notice a difference. You could do a benchmark though if you want to have numbers.

Basically, it works like this:

If you got a copy of Smarty in e.g. /var/www/app/libs/Smarty and another copy of it in PEAR and your include path is something like include_path="/var/www/app/libs:/php/pear" and you do a require 'Smarty.php', then PHP will first search in libs and immediately find Smarty. But without a local copy, PHP would still search the first include path, before it would search in PEAR, so it's a tiny (microseconds) bit slower. Nothing to worry about, unless you got many include paths. And of course, it depends on how you include paths are setup anyway. If PEAR comes first, then PHP will always search in there first. And if you use an absolute or relative path in require, the include path will be ignored altogether.

See the documentation for include and include_path for further details.


It doesn't matter at all when it comes to performance. PEAR does nothing special with the libs. In the end they are just included as usual.

PEAR just provides a comfortable way for installation and dependency tracking.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜