Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Alan Knowles' Blog:
require_once Optimization
Mar 18, 2005 @ 13:44:41

In yet another new posting from Alan Knowles's blog today, he asks the question: "Is require_once, one optimization too many?".

I noticed a small thread on pear-dev about require_once, the concept that having require_once to lazy load files, is slowing things down seems to crop up every so often. The crux of the issue appears to be the impression that lazy loading is slowing things down somehow, and that doing something like this may improve performance.

In early versions of PHP4.3, and before, each require_once call had to do quite a bit of work to determine if a file had already been included.

It made the assumption that you might have changed the include path, and therefore, the file you where requesting might actually not have been loaded. So each call went through your every path in your include_path, made sure each part of the directory existed, and the tried to open the file, this resulted in quite a few stat calls (via realpath), as well as a few opens.

According to the rest of this posting, this feature has a patch suggested for it, but no real progess as of yet...

tagged:

Link:


Trending Topics: