Page 1 of 1
include vs. include_once
Posted: Fri Jan 21, 2005 4:05 pm
by magicrobotmonkey
Whats bad about always using include_once instead of include? The only thing I can think of is scoping issues.
Posted: Fri Jan 21, 2005 4:30 pm
by feyd
I think it depends on the habits of the person. i.e. Are they include happy, or including libraries and functionality versus lazy/procedural.
Posted: Fri Jan 21, 2005 8:23 pm
by Christopher
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.