In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "what are the characteristics of php static method". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "what are the characteristics of php static method" can help you solve the problem.
The characteristics of static methods in PHP are: 1, static methods are modified with the static keyword; 2, static methods can be used anywhere in the code; 3, static methods can be accessed without instance objects; 4, static methods can only operate static variables, not non-static variables.
This article operating environment: Windows10 system, PHP7.1 version, Dell G3 computer.
What are the characteristics of php static method
Static methods are also called class methods, and static methods belong to all object instances: static function+ method name
Outside the class: class name:: class method name or object name-> class method name
Inside the class: self:: class method name or class name:: class method name
If a variable needs to be shared by all variables, static variables need to be introduced; if a method only manipulates static variables, use static methods
When you manipulate static variables, you need to manipulate static methods, and non-static properties (variables) cannot be accessed in static methods.
Characteristics of static methods:
1. Static methods can only manipulate static methods, not non-static variables.
two。 Ordinary member methods, which can manipulate both non-static and static variables
Advantages of static methods:
(1) it can be used anywhere in the code (assuming the class can be accessed)
(2) each instance of the class can access the static property defined in the class, and the static property can be used to set the value, which can be used by all objects of the class.
(3) static properties or methods can be accessed without an instance object.
Static methods cannot access the normal properties in this class because those properties belong to an object, but can access static properties.
This is the end of the content on "what are the characteristics of php static methods". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.