In my project, say I am instantiating a class named SubClass
, which extends an abstract class named AbstractClass
. At the top of my files I include a file named bootstrap.inc
, which includes AbstractClass
in every file. Then, when I need it, I include SubClass
which does not contain an include to AbstractClass
.
If I include AbstractClass
in the files of classes that extend it (such as SubClass
), sometimes I am using multiple sub-classes in one file and will get an error. I would rather not include AbstractClass
in every file via the bootstrap, since I am not always using it, but cannot think of a way to avoid this.
I have been advised that using include_once()
is a sign of poor design, so have avoided that, although it would be one solution.
Is there an alternative method to include_once()
?