Since you are overriding $name in the child, the property will have the value of the child property. Then you cannot access the parent value. This would not make any sense, since the property is publicly available, which means that the property is visible to the child (and outside of it), and changes in it will change the most basic value. Thus, it is effectively the same property and value for this instance.
The only way to have two separate properties of the same name is to declare the base property private and the child property not private, and then call a method that has access to the base property, for example
class Foo { private $name = 'foo'; public function show() { echo $this->name; } } class Bar extends Foo { public $name = 'bar'; public function show() { parent::show(); echo $this->name; } } (new Bar)->show();
Since your C ++ call uses the scope :: operator , you can look for class / static properties :
class Foo { static public $name = 'foo'; public function show() { echo static::$name;
source share