Home  >  Article  >  Backend Development  >  What is the meaning of php object

What is the meaning of php object

藏色散人
藏色散人Original
2021-12-06 10:13:424064browse

The object in php is a whole composed of information and a description of how to process the information. It is an abstraction of the real world. In the real world, everything we face are objects, such as computers. , TV sets, bicycles, etc.

What is the meaning of php object

The operating environment of this article: Windows 7 system, PHP version 7.4, DELL G3 computer

What is the meaning of the php object?

PHP Object-oriented

In object-oriented programming (English: Object-oriented programming, abbreviation: OOP), an object is a collection of information and The whole description of the processing of information is an abstraction of the real world.

In the real world, the things we face are objects, such as computers, televisions, bicycles, etc.

The main three characteristics of the object:

  • #The behavior of the object: what operations can be applied to the object, turning on the light and turning off the light are behaviors.

  • The shape of the object: how the object responds, color, size, and appearance when those methods are applied.

  • Representation of objects: The representation of objects is equivalent to an ID card, specifically distinguishing the differences in the same behavior and status.

For example, Animal is an abstract class. We can specify a dog and a sheep, and dogs and sheep are concrete objects. They have color attributes and can be written , you can run and other behavioral states.

Object-oriented content

Class − defines the abstract characteristics of a thing. The definition of a class includes the form of the data and the operations on the data.

Object − is an instance of a class.

Member variables − Variables defined inside the class. The value of this variable is invisible to the outside world, but can be accessed through member functions. After the class is instantiated as an object, the variable can become an attribute of the object.

Member function − Defined inside the class, it can be used to access the data of the object.

Inheritance − Inheritance is a mechanism for subclasses to automatically share data structures and methods of parent classes. This is a relationship between classes. When defining and implementing a class, you can do it on the basis of an existing class, take the content defined by the existing class as your own content, and add some new content.

Parent class − A class is inherited by other classes. This class can be called a parent class, a base class, or a super class.

Subclass − A class that inherits other classes is called a subclass or a derived class.

Polymorphism − Polymorphism means that the same function or method can act on multiple types of objects and obtain different results. Different objects can produce different results when receiving the same message. This phenomenon is called polymorphism.

Overloading − Simply put, it is a situation where functions or methods have the same name but different parameter lists. Such functions or methods with the same name and different parameters are called overloaded functions or methods. .

Abstraction − Abstraction refers to abstracting objects with consistent data structures (attributes) and behaviors (operations) into classes. A class is an abstraction that reflects important properties related to an application while ignoring other irrelevant content. The division of any class is subjective, but must be related to the specific application.

Encapsulation − Encapsulation refers to binding the properties and behavior of an object that exists in the real world and placing it in a logical unit.

Constructor − Mainly used to initialize the object when creating the object, that is, assign initial values ​​to the object member variables. It is always used together with the new operator in the statement to create the object.

Destructor − Destructor (destructor) Contrary to the constructor, when the object ends its life cycle (for example, the function in which the object is located has been called), the system automatically executes the destructor. Destructors are often used to do "clean-up" work (for example, when creating an object, use new to open up a memory space, which should be released with delete in the destructor before exiting).

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What is the meaning of php object. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn