Answer the question
In order to leave comments, you need to log in
Why is the property not available on the heir?
Guys, help me understand. Why the heir does not see the variable "year".
class Class1{
protected $year = 1;
public function setYear($year){
$this->year = $year;
}
}
class Class2 extends Class1{
public function getYear(){
return $this->year;
}
}
$class1 = new Class1();
$class1->setYear(2018);
$class2 = new Class2();
echo $class2->getYear(); //NULL
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question