Home > Backend Development > PHP Tutorial > Section 2 - Object Model of PHP5 - ClassesandObjectsinPHP52_PHP Tutorial

Section 2 - Object Model of PHP5 - ClassesandObjectsinPHP52_PHP Tutorial

WBOY
Release: 2016-07-13 17:24:22
Original
798 people have browsed it

| = This article is read by Haohappy > | = Notes from the Chapter Classes and Objects | = Translation + personal experience | = Please do not reprint to avoid unnecessary trouble that may occur, thank you | = Welcome to criticize and correct me, Hope to make progress together with all PHP enthusiasts! +------------------------------------------------ ---------------------------------------+ */ Section 2--Objects of PHP5 Model PHP5 has a single-inherited, restricted-access, overloadable object model. "Inheritance," discussed in detail later in this chapter, involves parent-child relationships between classes. In addition, PHP supports restrictions on properties and methods. access. You can declare members as private and not allow external classes to access them. Finally, PHP allows a subclass to overload members from its parent class. //haohappy Note: There is no private in PHP4, only public.private is better There are benefits to implementing encapsulation. PHP5's object model treats objects as different from any other data type and is passed by reference. PHP does not require you to explicitly pass and return objects by reference. More on this at the end of this chapter. Describes the handle-based object model. It is the most important new feature in PHP5. With a more direct object model, the handle-based system has additional advantages: increased efficiency, less memory usage, and greater flexibility. In In previous versions of PHP, scripts copied objects by default. Now PHP5 only moves the handle, which takes less time. The improvement in script execution efficiency is due to the avoidance of unnecessary copying. While the object system brings complexity, it also It brings benefits in execution efficiency. At the same time, reducing copying means occupying less memory and leaving more memory for other operations, which also improves efficiency. //haohappy Note: Based on handles, that is, two objects Can point to the same block of memory, reducing copy operations and memory usage. Zand Engine 2 has greater flexibility. A happy development is to allow destruction-executing a class method before the object is destroyed. This is also very good for utilizing memory, allowing PHP to clearly know when there are no references to the object and allocate the free memory to other uses.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532166.htmlTechArticle| = This article is read by Haohappy> | = Notes from the Chapter Classes and Objects| = Translated mainly + personal Thoughts | = Please do not reprint to avoid possible unnecessary trouble, thank you | = Criticisms and suggestions are welcome...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template