class Person {
public static function ShowQualification() {
}
}
class School {
public static $Headmaster = new Person(); // NetBeans complains about this line
}
Why is this not possible?
I want to be able to use this like
School::Headmaster::ShowQualification();
..without instantiating any class. How can I do it?
Update: Okay I understood the WHY part. Can someone explain the HOW part? Thanks 🙂
From the docs,
new Person()is not a literal or a constant, so this won’t work.You can use a work-around: