Is it possible for a parent to use a child's constant or static variables from inside a static metho
- by ryeguy
Below is an example of what I'm trying to do. The parent can't access any of the child's variables. It doesn't matter what technique I use (static or constants), I just need some kind of functionality like this.
class ParentClass
{
public static function staticFunc()
{
//both of these will throw a (static|const) not defined error
echo self::$myStatic;
echo self::MY_CONSTANT;
}
}
class ChildClass extends ParentClass
{
const MY_CONSTANT = 1;
public static $myStatic = 2;
}
ChildClass::staticFunc();