What is the static keyword in PHP?
Why Interviewers Ask This
Candidates at the intermediate level are expected to not only know this concept but explain the trade-offs involved. Interviewers use this question to see if you can reason about design decisions, not just recall facts.
Answer
The static keyword in PHP has multiple uses. Static class members (properties and methods) belong to the class rather than an instance — access with ClassName::$property or ClassName::method(). Static variables inside functions retain their value between function calls: function counter() { static $count = 0; return ++$count; }. Late static binding (using static:: instead of self::) refers to the class that was actually called at runtime, not where the method was defined — crucial for inheritance scenarios where you want to reference the child class from a parent method. self:: always refers to the class where the code is written; static:: refers to the runtime class.
Pro Tip
Back up your answer with a specific project or situation. Saying 'In my last PHP project, I used this when...' immediately makes your answer more credible and memorable.