In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you what is the difference between final and static in php, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The difference between final and static in php: 1, static is a static variable, static variable only exists in the local function domain, but when the program execution leaves this scope, its value is not lost; 2, final is used for the function, belonging to object-oriented usage, once used, this function cannot be changed and overloaded.
This article operating environment: Windows7 system, PHP7.1 version, Dell G3 computer
The difference between final and static in php
Static is a static variable, which exists only in the local function domain, but its value is not lost when the program execution leaves this scope.
For example, you can use it to calculate the cumulative number of function calls.
Static (static) keywords
This page explains using the static keyword to define static methods and properties. Static can also be used to define static variables and later static bindings. See the above page for the use of static in it.
If a class property or method is declared static, it can be accessed directly without instantiating the class. Static properties cannot be accessed through an object instantiated by a class (but static methods can).
Static method
Because static methods do not need to be called through an object, the pseudo variable $this is not available in static methods.
Calling a non-static method statically throws an Error.
Prior to PHP 8.0.0, the use of calling a non-static method statically had been deprecated and resulted in an E_DEPRECATED-level warning.
Fainal is used for functions and belongs to object-oriented usage. Once used, this function cannot be changed and overloaded.
PHP 5 adds a final keyword. If a method in the parent class is declared as final, the subclass cannot override the method. If a class is declared as final, it cannot be inherited.
These are all the contents of this article entitled "what's the difference between final and static in php". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.