Home >Backend Development >PHP Tutorial >What are the differences between the static keyword and the self keyword in PHP?
In PHP learning, many people confuse the static keyword and the self keyword. Many people think that the static keyword and the self keyword are the same. So are the static keyword and the self keyword the same? Let's summarize what are the differences between the static keyword in PHP and the self keyword?
Regarding the static keyword and the two terms self keyword, I believe many people will encounter it when getting started with PHP. Some people do not understand these two keywords. A lot. If you are learning PHP now, you must learn the difference between these two keywords.
1: What is the static keyword? What is the self keyword?
1. What is the static keyword?
In the PHP Chinese website manual, the description of the self keyword is that after setting the attributes of the class to static, you can access the static attributes without instantiating the object.
2.What is the self keyword?
The self keyword is used in object methods, and of course points to the current object. If it is in a class method, the self keyword represents the current class.
2: What are the differences between the static keyword in PHP and the self keyword?
1. The self keyword is an intra-class pointer, and self itself is also a strong For probes, let’s not worry about whether we have written a parent class, but the attributes of self all point to static.
2. In the static keyword, if you encounter an attribute that overrides the parent class, generally speaking, you will access the subclass.
The above is a complete introduction to the static keyword in PHP and the differences between it and the self keyword. If you want to know more about php programming from entry to mastery full set of video tutorials, please pay attention to the PHP Chinese website.
The above is the detailed content of What are the differences between the static keyword and the self keyword in PHP?. For more information, please follow other related articles on the PHP Chinese website!