Home  >  Article  >  Backend Development  >  What is PHP object-oriented and the three major characteristics of object-oriented

What is PHP object-oriented and the three major characteristics of object-oriented

巴扎黑
巴扎黑Original
2018-01-09 13:09:188500browse

What is object-oriented?

Object-oriented programming, which we often call OOP, is actually part of object-oriented programming. There are three parts to object-oriented: object-oriented analysis (OOA), object-oriented design (OOD), and object-oriented programming (OOP). What we are going to learn now is object-oriented programming, and the two first and most important concepts to understand in object-oriented programming are classes and objects.

Classes and Objects

Everything is an object. We can regard everything in the world as an object, because they all have their own attributes. For example: people have attributes such as height, weight, age, gender, etc., and they can also sing, dance, run and other behaviors. If people are regarded as a class, then height, weight, age, and gender are the attributes of the human class, and singing, dancing, and running are the behaviors of the human class.

You can try to look at the things around you. We can all regard it as a class. Give more examples to deepen your understanding of the concepts of classes and objects.

When we try to give examples, we are invisibly instantiating classes. For information on instantiating classes, please see: Definition and instantiation methods of php classes

Three major characteristics of object-oriented programming

(1). Encapsulation

The simple explanation is to put the function in a box , when you want to use this function, open the box, take it out and use it.

(2). Inheritance

Subclasses automatically inherit the properties and methods in 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 code reusability.

(3).Polymorphism

means that a class can create multiple objects and obtain different results.

The above is the detailed content of What is PHP object-oriented and the three major characteristics of object-oriented. 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