property = 'modifiedinparent';
}
public function PARENT_get_property()
{
return $this->property;
}
}
class Child extends ParentAbstract
{
public function set_property($value)
{
$this->property = $value;
}
public function get_property()
{
return $this->property;
}
public function append_property($str)
{
$this->property .= $str;
}
public function echo_property()
{
echo $this->property;
}
}
//client code
$str .= '
PHP version:'. phpversion();
$obj = new Child();
$str .= '
initialized property from perspective of child:'.$obj->get_property();
$obj->modify_property_within_parent();
$str .= '
modified property from perspective of child:'.$obj->get_property();
$str .= '
modified property from perspective of parent:'.$obj->PARENT_get_property();
$obj->append_property('Extra');
$str .= '
after appended to property from perspective of child:'.$obj->get_property();
$obj->set_property('hello');
$str .= '
after set in child from perspective of child:' . $obj->get_property();
$obj->append_property('Extra2');
$str .= '
after appended to property2 from perspective of child:'.$obj->get_property();
echo($str);
prints
PHP version:5.2.8
initialized property from perspective of child:
modified property from perspective of child:
modified property from perspective of parent:modifiedinparent
after appended to property from perspective of child:Extra
after set in child from perspective of child:hello
after appended to property2 from perspective of child:helloExtra2