In-depth Exploration of PHP object models [PHP topics]

Source: Internet
Author: User
Object-oriented programming is a major improvement in the software development theory. Before that, it was very difficult to use large software projects, especially those projects with hundreds of thousands of lines of source code, each correction may cause many side effects, each of which is effective.

Object-oriented programming is a major improvement in the software development theory. Before that, it was very difficult to use large software projects, especially those projects with hundreds of thousands of lines of source code, each correction may cause many side effects, and each function module may cause errors in other modules. In object-oriented programming, modules are organized into objects. These objects have methods and attributes. from an abstract point of view, methods are the actions of an object, and properties are the characteristics of objects. From the programming point of view, the method is a function and the attribute is a variable. In an imaginary object-oriented system, each part is an object. The system consists of objects and objects formed by methods.

Each language provides a different way to visit objects. When PHP was initially designed, or even when PHP3 was developed, PHP was not intended to provide large projects with more than 0.1 million lines of code. With the development of PHP and Zend engines, it is possible to develop large projects, but regardless of the scope of your project, writing your scripts using classes will allow code to be reused.

StartThe object model of PHP5 regards the object as different from any other data type and transmits it through reference. PHP does not request you to pass and return the object through reference explicitly. >>> View details

  Define a classWhen declaring a class, you need to list all variables and all functions that the object should have. these variables and functions are also called attributes and methods.>>> View details

Structure functions and DestructorPersistence is a strong effect of the class. One class (subclass/derived class) can continue the work of another class (parent class/base class. The derived class contains all the attributes and methods of the base class, and you can add other attributes and methods to the derived class.>>> View details

  Object replicationThe object model in PHP5 calls an object through reference, but sometimes you may want to create a copy of the object and expect that the transformation of the original object does not affect the copy. For this purpose, PHP defines a special method called _ clone.>>> View details

Visiting attributes and methodsThe attribute of an object instance is a variable, just like other variables in PHP. However, you must use the-> operator to reference them. You do not need to apply the dollar sign $ Before the attribute.>>> View details

Static Member of the class

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.