コード例 #1
0
ファイル: test.php プロジェクト: afliw/ponponpon
    private $name, $lastname;
    public function __construct($name, $lastname)
    {
        $this->name = $name;
        $this->lastname = $lastname;
    }
    public function GetFullName()
    {
        return $this->name . " " . $this->lastname;
    }
}
class ChildClass extends ParentClass
{
    private $age;
    public function __construct($name, $lastname, $age)
    {
        parent::__construct($name, $lastname);
        $this->age = $age;
    }
    public function GetAge()
    {
        return $this->age;
    }
    public function asd()
    {
        return $this->GetFullName();
    }
}
$obj = new ChildClass("Pedro", "Sanchez", 30);
echo "<p>Nombre completo: <b>{$obj->asd()}</b></p>";
echo "<p>Edad: <b>{$obj->GetAge()}</b></p>";