2

What is the difference between self and static keyword in static method.

I do understand that you could not extend static methods, you could, but they would always reference to parent method.

And static keyword inside static method solves that.

So does it means I can forget about self, and joust use static from now on? Or there are cases where I could use self?

Thanks.

1 Answer 1

1

I really cant explain it better or give better examples than the doc on Late Static Binding. So its not that you should always use one or another, its a question of whether you want/need to resolve the call up the inheritance chain (static::theMethod()) or whether you want the traditional behavior (self::methodName()). I'm sure there are use cases for both.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.