<?php
class Ivan
{
public function getName()
{
return "Ivan";
}
}
class Semyon extends Ivan
{
public function getName()
{
// вызываем метод из класса A
$parentName = parent::getName();
return "Semyon, son of $parentName";
}
}
$person = new Semyon();
echo $person->getName();
PD9waHAKCmNsYXNzIEl2YW4gCnsgCiAgICBwdWJsaWMgZnVuY3Rpb24gZ2V0TmFtZSgpIAogICAgeyAKICAgICAgICByZXR1cm4gIkl2YW4iOyAKICAgIH0KfQoKY2xhc3MgU2VteW9uIGV4dGVuZHMgSXZhbgp7CiAgICBwdWJsaWMgZnVuY3Rpb24gZ2V0TmFtZSgpCiAgICB7CiAgICAgICAgLy8g0LLRi9C30YvQstCw0LXQvCDQvNC10YLQvtC0INC40Lcg0LrQu9Cw0YHRgdCwIEEKICAgICAgICAkcGFyZW50TmFtZSA9IHBhcmVudDo6Z2V0TmFtZSgpOwogICAgICAgIHJldHVybiAiU2VteW9uLCBzb24gb2YgJHBhcmVudE5hbWUiOwogICAgfQp9CgokcGVyc29uID0gbmV3IFNlbXlvbigpOwplY2hvICRwZXJzb24tPmdldE5hbWUoKTsKCg==