include vs. include_once
Moderator: General Moderators
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
include vs. include_once
Whats bad about always using include_once instead of include? The only thing I can think of is scoping issues.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
The only downside to using include_once() might be the slight overhead of the data and lookup.
If you have inlcude files that in turn include base library files, then include_once() allows you to put includes in every file as needed and not worry about multiple definitions.
On the flip side, if you don't want a file included twice then use include() and the offending code will produce an error.
If you have inlcude files that in turn include base library files, then include_once() allows you to put includes in every file as needed and not worry about multiple definitions.
On the flip side, if you don't want a file included twice then use include() and the offending code will produce an error.