Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the php object?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what is the php object?" in the operation of actual cases, many people will encounter such a dilemma, and then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The object in php is a whole composed of information and the description of information processing, and it is the abstraction of the real world. In the real world, the things we face are all objects, such as computers, televisions, bicycles and so on.

This article operating environment: Windows7 system, PHP7.4 version, 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 whole composed of information and the description of information processing, and is an abstraction of the real world.

In the real world, the things we face are all objects, such as computers, televisions, bicycles and so on.

There are three main properties of an object:

The behavior of the object: those actions can be applied to the object. Turning on and off the light is the behavior.

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

The representation of the object: the representation of the object is equivalent to the ID card, specifically distinguishing what is different in the same behavior and state.

For example, Animal (animal) is an abstract class, we can be specific to a dog and a sheep, and dogs and sheep are specific objects, they have color attributes, can write, can run and other behavior states.

Object-oriented content

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

The object − is an instance of the class.

The member variable − is defined as a variable within the class. The value of the variable is invisible, but it can be accessed through a member function, and after the class is instantiated as an object, the variable becomes a property of the object.

The member function − is defined inside the class and can be used to access the data of the object.

Inheriting − inheritance is a mechanism by which subclasses automatically share parent data structures and methods, which is a relationship between classes. When defining and implementing a class, it can be done on the basis of an existing class, taking the content defined by the existing class as its own content, and adding some new content.

Parent class − A class that is inherited by another class can be called a parent class, or a base class, or a superclass.

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

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

Overloaded − simply means that functions or methods with the same name but different parameter lists are called overloaded functions or methods with different parameters.

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

Encapsulation − encapsulation refers to binding the attributes and behaviors of an object that exists in the real world and placing them in a logical unit.

The constructor − is mainly used to initialize the object when it is created, that is, to assign an initial value to the object member variable, which is always used in the statement that creates the object together with the new operator.

The destructor − destructor (destructor), in contrast to the constructor, automatically executes the destructor when the object ends its life cycle (for example, the function in which the object is located has been called). Destructors are often used to clean up the aftermath (for example, opening up a memory space with new when creating objects, which should be freed with delete in the destructor before exiting).

That's all for "what is the php object?" Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report