[UPHPU] require_once vs. class_exists
Sean
sean at lookin3d.com
Fri Apr 18 14:40:31 MDT 2008
That's wrong, if you install apc and use it's we interface, you can use
autoload and it will show that the all the files are getting cached.
Alvaro Carrasco wrote:
> Rusty Keele wrote:
>> Hi,
>>
>> Which is a better approach to use:
>> 1. require_once('path/to/class.php');
>>
>> or
>>
>> 2. if(!class_exists('path/to/class.php'))
>> require('path/to/class.php');
>>
>> I have been using the first approach in all my files where I need
>> to instantiate a specific class, but I am wondering if the second
>> approach is more efficient? Are there any benefits to using the
>> second approach - such as less caching of objects - or do these two
>> statements do the same thing?
>>
>> Thanks,
>> Rusty
>>
>>
>>
>>
>
> Keep in mind that f you are using a byte-code cache such a APC or
> eAccelerator (you're using one, right :) ), it probably won't be able
> to cache the code for classes that are included conditionally.
> So, the performance when using a byte-code cache generally goes
> something like this:
>
> require best
> require_once ok
> autoload or conditional include bad
>
> Alvaro
>
>
> _______________________________________________
>
> UPHPU mailing list
> UPHPU at uphpu.org
> http://uphpu.org/mailman/listinfo/uphpu
> IRC: #uphpu on irc.freenode.net
>
>
--
Sean Thayne,
Exit12
More information about the UPHPU
mailing list