How do I access the static variables of a derived class in a base class method?

class B {
public static $s = "baked;
public function m () {
echo self::$s; / /" B"
/ / $this actually points to the instance of D, how can I access the DVDs?
}
}

class D extends B {
public static $s = "Downs;
}

$d = new D ();
$d-> m ();

of course I know that Class D can redefine function m, but I wonder if there is a way not to redefine it. Thank you!

Php
Jul.06,2021

make good use of code format

<?php

class B
{
    static $s = 'B';
    
    public function m() {
        echo static::$s;
    }
}

class D extends B
{
    static $s = 'D';
}
// output: D
(new D)->m();
Menu