<?php class Foo { private $bar = 'baz'; public function __construct() { unset($this->bar); } public function getFooBar() { return $this->bar; } } class Bar extends Foo { private $bar = 'baz'; public function __construct() { parent::__construct(); unset($this->bar); } public function getBarBar() { return $this->bar; } } $bar = new Bar(); var_dump($bar->getFooBar()); // notice + null var_dump($bar->getBarBar()); // notice + null $rBarBar = new ReflectionProperty(Foo::class, 'bar'); $rBarBar->setAccessible(true); $rBarBar->setValue($bar, __LINE__); var_dump($bar->getFooBar()); // line no. var_dump($bar->getBarBar()); // notice + null
You have javascript disabled. You will not be able to edit any code.