: This article mainly introduces (8) the four principles of object-oriented design. if you are interested in PHP tutorials, please refer to them. I. replacement principle:
1. child classes must be replaced with their base classes and appear anywhere the parent class can appear.
2. problems to be solved by the LSP principle:
A. how to correctly design the inheritance
B. how to obtain the optimal hierarchy of inheritance
C. avoid the class hierarchy being designed into a situation that does not conform to the OCP principle
3. follow these principles:
A. All methods of the parent class must be implemented or overwritten in the subclass, and the derived class only implements the methods declared in its abstract class, but no redundant method definitions or implementations can be provided.
B. in the client program, only parent class objects should be used instead of subclass objects. In this way, you can bind data during runtime. (Dynamic polymorphism)
II. example:
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.
The above section introduces (8) the four principles of object-oriented design, including content, and hopes to help those who are interested in PHP tutorials.