Can this be used in php static methods?

青灯夜游
Release: 2023-02-28 20:38:02
Original
4063 people have browsed it

Can this be used in php static methods?

This cannot be used in static methods

Static methods are loaded as the class is loaded, and static methods exist prior to objects. When we load a class, the object does not exist yet, and this represents a reference to the object. When we load the class, the object does not exist, so how can we use this? The answer is obvious

this refers to the current object. Static methods are methods called through classes and do not need to be instantiated. Since there is no need to instantiate, there is no current object. Since there is no current object, there will be no this

For more related knowledge, please pay attention to PHP Chinese website! !

The above is the detailed content of Can this be used in php static methods?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!