9 key points for object orientation _ PHP Tutorial

Source: Internet
Author: User
The nine key points of object-oriented thinking. 1. object-oriented elements 1. abstraction, 2. encapsulation, 3. sharing, 4. the three main characteristics (encapsulation, inheritance, and polymorphism) of the object structure rather than the object-oriented program structure lack one or more elements of the object-oriented
1. abstraction, 2. encapsulation, 3. Sharing, 4. emphasizing the object structure rather than the program structure

Three characteristics of object-oriented (encapsulation, inheritance, polymorphism) are indispensable

II. class MyPc {
Public $ name;-> member attributes (which can be understood as custom variables)
Var $ price;
Function vod () {-> Member method (the amount can be a custom function)
Return "bkJia video tutorial ";
}
}
$ Pc1 = new MyPc ();-> instantiate class
$ Pc1-> name;-> use-> access object content

3. OOp object Oriented Program explanation: Program Wizard Development

4. The $ this keyword is a system variable used to access the object attributes and object methods of the current object.

5. destructor: a method that can be automatically called when an object is released is called a destructor.

6. encapsulation Keywords: public, protected, and private
Encapsulate related functions: __set (), _ get ()

7. public indicates global, and internal and external subclass of the class can be accessed;
Protected indicates that it is protected and can be accessed only in this class or subclass or parent class;
Private indicates private, which can only be used inside the class;

8. Inheritance Keywords: extends single inheritance

9. base class method overloading and parent class method access overloading method base class name: method name

Abstraction 1. abstraction, 2. encapsulation, 3. Sharing, 4. emphasizing the object structure rather than the three main characteristics of the object-oriented program structure (encapsulation, inheritance, polymorphism) is missing...

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.