What is the difference between self and this pointer?

Something is not quite clear.


Answer 1, authority 100%

In php self– point to a class, for example, if there is a class AAA and it has a static func method, then you can call it from anywhere through AAA::func() (if it is public of course ).

However, if you want to call a static method from an instance of the current class or another static method of the current class, then php provides a shorthand alias of self::func() which is equivalent to AAA::func() within the current class. The benefit of self is obvious if the name of the current class is more than 4 characters 🙂 and besides, it will be easier to rename the class later – you won’t have to rewrite its name everywhere in the code of this class.

this– a pointer to a class instance, inside the executable method of this instance (object).