Is it possible to either
extend an extension of a class e.g.:
class a {
}
class b extends a {
}
class c extends b {
}
EDIT:
[or some other way that class c can use functions only defined in b but not in a.]
Well I just notice that my question was kinda messed up. c should be able to use all functions, so of course those of a aswell.
I’ll just accept the answer solving my non-existing problem, in case someone searches for this.
Since PHP 5.4 you can use traits which may be of help to you. You can define two traits, one with the functions that class
ahas and one containing functions that classbhas, but not classa.So:
Then you can define a class
athat uses onlyTraitA, a classbthat uses both traits, and a classcthat uses onlyTraitB:More on traits: http://php.net/manual/en/language.oop5.traits.php
Keep in mind that you have to pay attention to your function names between different traits. You can’t have the same functionnames in both traits or you’ll get collisions.