Yes, it is possible, but it should actually be written like this:
class dostuff extends config {
public static function get_url(){
echo parent::$base_url;
}
}
self::$base_url, static::$base_url - . , :
self::$base_url , ,static::$base_url , ( " " ).
:
class config {
public static $base_url = 'http://config.example.com';
public function get_self_url() {
return self::$base_url;
}
public function get_static_url() {
return static::$base_url;
}
}
class dostuff extends config {
public static $base_url = 'http://dostuff.example.com';
}
$a = new config();
echo $a->get_self_url(), PHP_EOL;
echo $a->get_static_url(), PHP_EOL;
$b = new dostuff();
echo $b->get_self_url(), PHP_EOL;
echo $b->get_static_url(), PHP_EOL;