Skip to content
Advertisement

Tag: inheritance

How do you set the value of a parent class variable in an inherited class but then use it in an inherited function?

I have the following. Currently it doesn’t output anything for “$this->aa”. I want to be able to inherit the class, set some variables, then call the parent class functions to act on it. Am I going about this the wrong way? Answer The problem here is the visibility of $aa. https://www.php.net/manual/en/language.oop5.visibility.php private $aa make $aa only visible for class A

Advertisement