Home > Article > Backend Development > The difference between class inheritance and overwriting, the difference between class inheritance and overwriting_PHP tutorial
Class inheritance is that there is an inheritable member A in the parent class, but not in the child class If there is a member with the same name, the member will be inherited to the subclass. When the subclass object accesses the member, it will actually access the corresponding member of the parent class.
Class rewriting means that there is an inheritable member A in the parent class, and a member with the same name exists in the subclass, so that the member will be overridden by the subclass. When the subclass object accesses the member, the actual accessed Is a member of the subclass.
So the difference between the two is that when overriding, the overridden members accessed have nothing to do with the parent class, while when inheriting, the members of the parent class are accessed.