Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
464 B
1
Indexable
Never
<?php
class Student{
    private $name;
    private $age;
    public function __construct($name,$age)
    {
        $this->name = $name;
        $this->age = $age;
    }
    public function getInfo(){

        return(print_r($this));
    }
}
$student2 = new Student("hari",223);
$student2->getInfo();
class Topper extends Student{
    public function getInfo(){
        return parent::getInfo();
    }
}
$student3 = new Topper("Peter",23);
$student3->getInfo();
?>