What are the three major characteristics of php?
The three major characteristics are: encapsulation, inheritance, and polymorphism
The so-called encapsulation is to encapsulate objective things into abstract Class, and the class can allow its own data and methods to be operated only by trusted classes or objects, and hide information from untrusted ones.
Encapsulation is one of the characteristics of object-oriented and the main characteristic of object and class concepts. Simply put, a class is a logical entity that encapsulates data and code that operates on this data. Within an object, some code or some data can be private and cannot be accessed by the outside world. In this way, objects provide varying levels of protection for internal data to prevent unrelated parts of the program from accidentally changing or incorrectly using the private parts of the object.
The so-called Inheritance refers to a method that allows an object of a certain type to obtain the attributes of an object of another type. It supports the concept of hierarchical classification.
Inheritance refers to the ability to use all the functionality of an existing class and extend these functionality without rewriting the original class. The new class created through inheritance is called a "subclass" or "derived class", and the inherited class is called a "base class", "parent class" or "super class". The process of inheritance is the process from general to special. To achieve inheritance, you can achieve it through "Inheritance" and "Composition". There are two types of ways to implement the concept of inheritance: implementation inheritance and interface inheritance. Implementation inheritance refers to the ability to directly use the properties and methods of the base class without additional coding; interface inheritance refers to the ability to only use the names of properties and methods, but the subclass must provide implementation;
So-called Polymorphism means that the same method of a class instance has different manifestations in different situations.
Polymorphism allows objects with different internal structures to share the same external interface. This means that although the specific operations on different objects are different, they (those operations) can be called in the same way through a common class.
Recommended: "PHP Tutorial"
The above is the detailed content of What are the three major characteristics of php. For more information, please follow other related articles on the PHP Chinese website!