Later, static binding will only work for new variable / method definitions. Thus, in your example, the $color Super property will always be changed instead of ChildA or ChildB . To use late static binding, you need to use the static instead of self . In addition, you need to override the $color property for the ChildA and ChildB :
class Super { protected static $color; public static function setColor($color){ // static instead of self static::$color = $color; } public static function getColor() { // static instead of self return static::$color; } } class ChildA extends Super { protected static $color; } class ChildB extends Super { protected static $color; } ChildA::setColor('red'); ChildB::setColor('green'); echo Super::getColor(); // prints nothing (NULL = ''), expected echo ChildA::getColor();// prints red echo ChildB::getColor();// prints green
source share