It seems to me that for "good, clean code", you would *always* want to use a xxxxx_once() function.
Is there any reason why you would prefer to use include (or require) instead of include_once (or require_once)? Is there less overhead, or would there be a reason to inlcude/require something multiple times?
A curiousity regarding include vs. include_once
Moderator: General Moderators
- ReverendDexter
- Forum Contributor
- Posts: 193
- Joined: Tue May 29, 2007 1:26 pm
- Location: Chico, CA
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
In procedural programming, using an "include" essentially inlines the code you want into the PHP document. Using functions, however, should make this unnecessary, and this sort of system can get very messy if not done with discipline.
There is less overhead for just include/require versus include_once/require_once, however, it is usually quite negligible.
There is less overhead for just include/require versus include_once/require_once, however, it is usually quite negligible.
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
I always use include_once, because I set up every file to be able to work independently, so they need to each be able to include the necessary files. However, since a lot of those overlap, include_once helps out.
The alternative to it would be how C++ header files are handled by giving each one a unique definition and checking if it is defined(). As long as include_once is available, I'll chose that method over the C way.
The alternative to it would be how C++ header files are handled by giving each one a unique definition and checking if it is defined(). As long as include_once is available, I'll chose that method over the C way.
I <3 namespaces...
Code: Select all
from mylib.forms import myform
import mylib.settings
def someFunc():
print myform(settings.form)