Answer the question
In order to leave comments, you need to log in
Why will output Fatal Error?
abstract class First {
private $a = 5;
abstract public function getVar();
}
class Second extends First{
public function getVar()
{
return $this->a;
}
}
$obj = new Second();
$obj->getVar();
Answer the question
In order to leave comments, you need to log in
The $this->a property is declared private. Therefore, it will not be available in child classes.
But in general it is Notice. At least on php 7.1 (I checked)
notice if a variable is declared. and fatal if there is no class property. And you have your own class property that is missing
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question