FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Is there any situation where anything other than require_once is better?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Is there any situation where anything other than require_once is better? [message #171954 is a reply to message #171928] Sun, 23 January 2011 09:20 Go to previous messageGo to previous message
Ross McKay is currently offline  Ross McKay
Messages: 14
Registered: January 2011
Karma:
Junior Member
"Leonardo Azpurua" wrote:
>> [require vs. require_once]
>>
>> But now I am going to start coding classes, and if they are going to
>> be completely context independent, they must declare their own
>> dependencies as "require" statements.
>>
>> And I guess "require_once" is the natural choice for this situation.

"Michael Fesser" wrote:
> In case of classes there's another very convenient option: autoloading.
>
> Have a look at __autoload() or better spl_autoload_register().

In such case, require() is sufficient because the autoloader will only
be called when the class has not yet been defined, and thus the file has
not yet been included / required. And require() has a (very tiny)
performance benefit over require_once() because the latter needs to
record and remember scripts that must not be reloaded. (OK, 2/3 of 3/5
of bugger all, but > 0)
--
Ross McKay, Toronto, NSW Australia
"There is more to life than simply increasing its speed." - Gandhi
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Syntax for trim charlist?
Next Topic: SNMPv3 for PHP?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 21:13:19 GMT 2024

Total time taken to generate the page: 0.07404 seconds