Hi Ken,

Because the require_once() is conditional, it's not actually seen as a straight 
forward include (you can't predict whether to require the file until that code 
block is executed). As a result, although the file is cached, the class/etc. in 
it are done so separate to the main code. Net result is that the cache is not 
as effective. In essence, autoloading has the same effect - you don't know what 
to include until a class is actually used and autoload is finally called - same 
effect as a conditional.

regards,
Pádraic
 
Pádraic Brady
http://blog.quantum-star.com
http://www.patternsforphp.com


----- Original Message ----
From: Ken Stanley <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wednesday, January 10, 2007 5:12:25 PM
Subject: Re: [fw-general] ZF and Autoloading

If I may chime in and ask, what -- if any -- problems could arise from wrapping 
each require/require_once with a condition to see if __autoload() is defined?

For example, in my bootstrap I do the following:

function __autoload($className) {

    Zend::loadClass($className);
}

And then in every file that I need to load a library, I do:

if (!function_exists('__autoload')) {
    require_once 'Zend/Path/To/Component.php';

}

Would this be a sufficient way to go between both situations? If I need to 
disable autoloading, I don't have to worry about my code breaking, and if I do 
use autoload then I'm not wasting a call to the require or include functions.


-- 
It looked like something resembling white marble, which was
probably what it was: something resembling white marble.
                -- Douglas Adams, "The Hitchhikers Guide to the Galaxy"






 
____________________________________________________________________________________
Any questions? Get answers on any topic at www.Answers.yahoo.com.  Try it now.

Reply via email to