What are the three main features of PHP object-oriented and object-oriented

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.