0
私は私がPHPへのアクセスの子供の保護値
class SuperClass{
static protected $message = "This is the parent";
public static function showMessage(){
echo self::$message."<br/>";
}
}
class SubClass1 extends SuperClass {
static protected $message = "This is the first child";
}
class SubClass2 extends SuperClass {
static protected $message = "This is the second child";
}
SuperClass::showMessage();
SubClass1::showMessage();
SubClass2::showMessage();
私が見ることを期待する
This is the parent
This is the first child
This is the second child
しかし、プロパティに定義する親と子でメソッドの抽象化をしたい、このコードを持っているもの私は持っています
This is the parent
This is the parent
This is the parent
なるほどために働くだろう「静的」
で親クラスのキーワード「自己」を交換してください!これだよ!どうも :) –