In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
I. static variables
In the above example, the local variable $an in the function is declared as a static variable using the static keyword, with an initial value of 0. 0. When the function is executed for the first time, the static variable $a changes from the initial value of 0 to 1. When the function is executed for the first time, the static variable $an is not released, but the result is saved in static memory. On the second execution, $a gets the result of the previous calculation from memory, continues the calculation, and stores the result 2 in the static memory space. Each time the function is executed in the future, the static variable will get the previous storage result from its own static memory space and calculate it as the initial value.
II. The use of the static keyword
Static members in a class are accessed directly using the class name instead of an object, in the following format:
Class name: static member property name; / / static member attribute can be accessed in this way both outside the class and in member methods
Class name: static member method (); / / static member method can be accessed in this way both outside the class and in member methods
In member methods declared in the class, you can also use the keyword "self" to access other static members. Because a static member belongs to a class, not to any object, it cannot be referenced with $this, and the self keyword provided to us in PHP is the keyword used to represent the class in the class's member methods. The format is as follows:
Self:: static member property name; / / use this way to access static member properties in this class in the member methods of the class
Self:: static member method name (); / / access static member methods in this class in this way in the member methods of the class
The result of the code running is 3 / 3
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.