|
Posted by Matthew Weier O'Phinney on 04/06/05 05:33
* GamblerZG <gambler@highstream.net>:
> > What fancy logic? And why does no one need it?
>
> I'm referring to this:
> http://archives.devshed.com/a/ng/557-22943/
Interestingly, I didn't see the so-called optimized code posted for
public consumption. If the person who started that thread was serious,
s/he should submit it to the PHP developers for review -- or become a
PHP developer. Heresay like that gets nobody anywhere.
As for the 'fancy logic', include_once does, among other things:
* Checks to see if the requested file has been include'd once already
* Checks to determine if the include path has changed since the last
time it was include'd
* If the include path *has* changed, stats the file to determine if
it's actually different
A sample use:
I'm in a class. In the class, each method represents a different run
mode, or screen, of an application: splash screen, listing of resources,
form for searching, form for adding a resource, etc.
For each dependency, I could 'require_once' a file, or simple 'require'
it, but here's the deal: I want to lazy load my dependencies. If I'm
showing the splash page, I don't necessarily want to load my pagination
class or my validation class. Likewise, I'm hesitant about include'ing
these files, because I may have other files elsewhere in the execution
chain that will also be loading them -- and that could cause errors
(redefining a class or function).
'include_once' allows me to lazy load -- and thus optimize my
application. Sure, it may be a slight performance hit -- but not nearly
that of loading the files in question.
--
Matthew Weier O'Phinney | WEBSITES:
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:matthew@garden.org | http://vermontbotanical.org
[Back to original message]
|