The second section - object model of php5 - Classes and Objects in PHP5 [2]

zhaozj2021-02-16  48

The second section - object model of php5 - Classes and Objects in PHP5 [2]

Author: Leon Atkinson translation: Haohappy Source: Beyond the PHP / * ------------------------------------ ------------------------------------------ | = This article is HaohappY << CORE PHP Programming >> | = Classes and Objects Chapter Note | = Translate Main Personal Experience | = To avoid unnecessary troubles, please do not reprint, thank you | = Welcome criticism, hope and all PHP enthusiasts progress together! ----------------------------------------- ---------------------------------- * / 2 - php5 object model PHP5 has A single inheritance, restricted access, overloaded object model. This chapter will discuss the "inheritance" of this chapter, including the parent-child relationship between the class. In addition, PHP supports restrictive access to attributes and methods. You can declare that member is private, not allowing external class access. Finally, PHP allows a subclass to overload members from its parent class .//haohappy Note: There is no private in PHP4, only public.private for better implementation packaging Very good. The object model of php5 regards the object different from any other data type, passed through reference. PHP does not require you to pass and return to objects by reference (Reference). In this chapter, the final will explain the handle according to the handle Object model. It is the most important new feature in PHP5. With a more direct object model, the handle-based system has additional advantages: efficiency, less memory, and more flexibility. Before PHP In several versions, the script defaults to copy objects. Now PHP5 mobile handles, require less time. The improvement of script execution efficiency is due to avoiding unnecessary replication. In the same time, it also brings Revenue efficiency. At the same time, reduced replication means that less memory can be accounted for more memory to other operations, which also enhances efficiency .//haohappy Note: Based on handle, two objects can point to the same A piece of memory reduces the copying action, and reduces the occupation of memory. Zand Engine 2 has greater flexibility. A happy development is to allow destructor - perform a class method before the object is destroyed. This is the utilization Memory is also very beneficial, let PHP clearly know when there is no reference to an object, assigns empty memory to other purposes.

转载请注明原文地址:https://www.9cbs.com/read-21575.html

New Post(0)