What is object-oriented?
Object-oriented programming, which we often call OOP, is actually part of the object-oriented. There are 3 parts to object-oriented: Object-oriented Analysis (OOA), Object-oriented design (OOD), Object-oriented programming (OOP). What we are going to learn now is object-oriented programming, and two of the most important concepts in object-oriented programming are classes and objects.
Classes and objects
All things are objects, all things in the world we can be regarded as objects, because they all have their own attributes. For example: People have height, weight, age, gender and so on these attributes, but also can sing, dance, run and so on behavior. If you look at people as a class, then height, weight, age, gender are the attributes of people, and singing, dancing, and running are people's behavior.
You can try to look at things around us, and we can all think of it as a class, more examples, to deepen our understanding of the concepts of classes and objects.
When we try to instantiate a child, it is virtually in the instantiation class, the contents of the instantiation class are as follows: the definition and instantiation method of PHP class
Three characteristics of object-oriented programming
(1). Encapsulation
The simple image of the explanation is that the function in a box, in order to use this function, open the box, remove it can be used.
(2). Inheritance
Subclasses automatically inherit properties and methods from one or more parent classes, and can override or add new properties or methods.
This feature simplifies the creation of classes and objects and improves the reusability of the code.
(3). polymorphism
Refers to a class that can create multiple objects and get different results.