First of all, include is a command that reads the php source file and processes it, since it was written instead of the include directive. You can use it in any php source file and are not related to class inheritance.
By the way, if you do not include the file containing the class A source code, you cannot extend this class.
Extending a class with the extends keyword implies the concept of inheritance, which is a key concept in object-oriented programming.
You get a class (A) with some methods and need a similar class (B) with a little different behavior, you can get a new extig class of class A and modify only the methods that need to be changed (it is called redefinition) or adding new ones.
In contrast to inheritance, there is composition. With composition, you do not extend the class to change its behavior; instead, you need to patch classes to get the desired behavior.
In wikipedia you can find a more detailed explanation of the composition of the object and [class inheritance] ( http://en.wikipedia.org/wiki/Inheritance_(computer_science))
There seems to be some confusion in these concepts as you extend your class A and at the same time try to compose it (by the way, the correct syntax is $ a = new B () ;. )
Useful link, obviously [Gof, Design patterns] ( http://en.wikipedia.org/wiki/Design_Patterns_(book))
Eineki
source share