Actually,
This is working fine.. but i want the parent value.
not a child value..
<?php
class Fruit{
protected $parentproperty = "parentvalue";// this is parent value
}
class Orange extends Fruit{
protected $parentproperty = "child value";// here i mentioned once again
function showParentProperty(){
return self::$this->parentproperty;
}
}
$obj = new Orange;
echo $obj->showParentProperty();
//conclusion:
// i want to get the parent value not child. its working fine . but it's displaying chid value
?>
If what you mean is this:
Then there is no way to do what you want because all nonstatic class properties in PHP are effectively virtual.
You could only use the
parentkeyword if the parent property was static, like this:If we ‘re talking about an instance property, then the only thing you can do is use another name for the child property.