What is late static binding in PHP?
Why Interviewers Ask This
This question targets practical, hands-on experience with PHP. Interviewers want to see if you've worked with these concepts in real projects, not just read about them. Strong answers include concrete examples.
Answer
Late static binding (LSB), enabled by static::, allows a method defined in a parent class to reference the class it is called on at runtime, not the class where the method is defined. self:: always resolves to the class in which the method is written — even if a child class overrides the property. static:: resolves to the class that was actually called. Example: if ParentClass has a static factory method using return new static();, calling ChildClass::create() returns a ChildClass instance. Using return new self(); would always return a ParentClass instance. LSB is essential for building fluent query builders, active record patterns, and other class-hierarchy-aware patterns.
Pro Tip
If you're unsure about a detail, say so honestly and explain your reasoning. Interviewers respect candidates who can think through uncertainty rather than bluffing.