Answer the question
In order to leave comments, you need to log in
Will a protected static property of a child class be visible in another child class?
Hello!
We continue to tinker with OOP: The protected modifier allows access to the class itself, classes that inherit it, and parent classes.
class A{
// тут мы видим self::$a
}
class B extends A{
protected static $a;
}
class C extends A{
// тут мы не видим self::$a
}
Answer the question
In order to leave comments, you need to log in
will not. a-priory.
<?php
class A{
// тут мы видим self::$a как????
public static function Foo() {
echo self::$a;
}
}
class B extends A{
protected static $a;
}
class C extends A{
}
$a = new A();$b=new B();$c = new C();
var_dump($b instanceof A, $c instanceof A, $b instanceof C, $c instanceof B);
A::Foo();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question