I need to bea be able to use a static variable set in a class that extends a base class... from the base class.
Consider this:
class Animal {
public
In PHP 5.3+, the following would be preferred:
class Animal {
public static $color = 'black';
public static function get_color()
{
return static::$color; // Here comes Late Static Bindings
}
}
class Dog extends Animal {
public static $color = 'brown';
}
echo Animal::get_color(); // prints 'black'
echo Dog::get_color(); // prints 'brown'
Late Static Bindings (PHP.net)