In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "detailed explanation of the magic methods of php". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "detailed explanation of the Magic method of php".
Since PHP 5, classes in PHP have been able to use magic methods. It stipulates that methods that begin with two underscores (_ _) are reserved as magic methods, so it is recommended that function names should not start with _ _, unless it is to overload existing magic methods. PHP keeps all class methods that start with _ _ (two underscores) as magic methods.
_ _ toString () and _ _ invoke ()
Public string _ _ toString (void): this method is called automatically when the object is used as a string. This method must return a string
The copy code is as follows:
_ _ invoke (): this method is called automatically when the object is called as a method.
The copy code is as follows:
_ _ call () and _ _ callStatic ()
_ _ call (): when an object accesses a method name that does not exist, the _ _ call () method is called automatically
_ _ callStatic (): when an object accesses a static method name that does not exist, the _ _ callStatic () method is called automatically
Through these two methods, calls to the name of the same method can correspond to different method implementations.
The copy code is as follows:
_ _ get () and _ _ set ()
_ _ set () is called when assigning a value to an inaccessible property
When reading the value of an inaccessible attribute, _ _ get () is called
The copy code is as follows:
When reading the value of an inaccessible attribute, _ _ get () is called
The copy code is as follows:
_ _ isset () and _ _ unset ()
_ _ isset () is called when isset () or empty () is called on an inaccessible attribute
_ _ unset () is called when unset () is called on an inaccessible attribute
The copy code is as follows:
At this point, I believe you have a deeper understanding of the "detailed explanation of the magic methods of php". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.