Home  >  Article  >  Backend Development  >  Can this be used in php static methods?

Can this be used in php static methods?

青灯夜游
青灯夜游Original
2020-04-25 17:54:124218browse

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!

Statement:
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 admin@php.cn
Previous article:What is php server?Next article:What is php server?