How can I refer to a variable or function defined by a class child?
In PHP, I’ve created an abstract class. This class is supposed to be able to compare a given version number with a number that has been set by its children.
Now, I tried referring to self::VERSION, which is a class constant that its children define. However, I could understand PHP not being able to do this because it cannot be sure that the constant is defined.
However, I then tried to add an abstract function getVersion(), so that you could be sure that children classes would have that function defined. However, when calling self::getVersion(), PHP complains about not being able to call an abstract function. In other words: when the parent class calls self, in an instance of a children class that will refer to the parent.
Now, is there a way for me to refer to a variable of method of a child class?
This question is in the General Section. Responses must be helpful and on-topic.