Re: Structured Code vs. Performance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tomi Kaistila wrote:

...

> 
> You can avoid duplication by only using require_once or include_once. PHP

indeed require_once() and include_once() help with maintainability but it
should be mentioned that if you are going to use an op-code cache (as Rob
Cummings mentioned also) then it is highly recommended that you stick to
using require() and include() as, IIRC, op-code caches handle your includes
much faster when they are 'unconditional' (probably not the correct word in this
context but what I mean is that there is no check to see if the file has been
previously included)

also using an absolute path in your include statements helps php (and the
op-code cache if you use it) it go a little faster because there is no need
to work through the directories defined in the include_path ini setting to
find the file.

> automatically does the checking that the file is not included if it has
> already been included once. The Zend framework works this way for instance.
> Just simply require_once, at the beginning of the file, everything the file
> in question needs.
> 
> Constants on the global scope are a bit of a different case. But if you do a
> lot of objects, you can instead of the global scope put all of your
> constants into classes, which works just as well. This avoids name
> conflicts.
> 
> Hope that answered your question.
> 
> 
> Tomi Kaistila
> PHP Developer
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux