The encapsulation of the three main features of PHP object-oriented

Source: Internet
Author: User
The object's members (properties, methods) are combined into a separate unit, and the inner details of the object are hidden as much as possible.

Here to introduce the "private" keyword, private, with this keyword decorated members, can only be accessed within the object, can not be accessed outside the object

The role of encapsulation methods

Can only be used internally after the 1.private package

2. There are 100 methods in a class that encapsulate 90 (methods for the other 10 services), and only 10 methods can be used

The role of encapsulation properties

1. The member property is equivalent to the global variable of this object, the member property is used in the method, the change of the member property is changing the execution behavior of the method, that is, changing the function of the object.

2. Don't let the object change or read his value outside

The above describes the PHP object-oriented three characteristics of the package, including the content of the text, I hope that the PHP tutorial interested in a friend helpful.

  • 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.