Problem Statement
What is late static binding in PHP and why is it used?
Explanation
Late static binding allows a child class to reference static methods or properties defined in the parent class using the static keyword instead of self. It ensures that methods refer to the class where they are actually called, not where they are defined.
Example:
class A { static function who(){ echo __CLASS__; } static function test(){ static::who(); } }
class B extends A { static function who(){ echo __CLASS__; } }
B::test(); // Outputs B
Code Solution
SolutionRead Only
class Base { static function who(){} static function call(){ static::who(); } }