class GrandClass {
public $data;
public function __construct() {
$this->someMethodInTheParentClass();
}
public function someMethodInTheParentClass() {
$this->$data = 123456;
}
}
class MyParent extends GrandClass{
public function __construct() {
parent::__construct();
}
}
class Child extends MyParent {
// public $data;
public function __construct() {
parent::__construct();
}
public function getData() {
return $this->data;
}
}
$a = new Child();
var_dump($a->getData());
PHP Примечание: Undefined переменной: данные в D: \ test.php в строке 7в PHP почему не работает
PHP Фатальная ошибка: Не удается получить доступ к пустой недвижимости в D: \ test.php в строке 7
Try: $ this-> данные –
использовать $ this-> данные не $ это -> $ данные –
$ this-> данные вместо $ это -> $ данных –