Home >Backend Development >PHP Tutorial >Section 2 - Object Model of PHP5 - ClassesandObjectsinPHP52_PHP Tutorial
| = 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.