this question has answer here:
in particular example, have parent class , children classes inheriting parent.
in parent class, have public variable called $abc , method called abc():
public $hello = 'hi'; class abc { function abc() { ... } }
inherited child class:
class def extends abc { function def() { parent::abc(); echo $this->hello; } }
my question is, why use parent:: access method parent class, use $this-> access variable, instead of parent:: well? sticking $this-> know theory behind that.
class def extends abc { function abc() { return parent::abc(); // here use parent! } }
you use parent::
call method belong parent might/was overridden child.
Comments
Post a Comment