php – What is static used for in the :: operator?

Question:

What is static used for in the :: operator?

return static::Find($id);

Answer:

The static keyword is used for late static linking, i.e. in the classes inherited from this, you can define your own static method Find () and it will be called, and not the method of the current class. If you specify self instead of static, then the static Find () method of the current class will be called, even if you define your own static Find () methods in inherited classes.

Since static methods do not belong to objects, but to classes, you have to sort out the situation with their redefinition using separate keywords.

Scroll to Top