-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInheritance.php
More file actions
37 lines (36 loc) · 774 Bytes
/
Inheritance.php
File metadata and controls
37 lines (36 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
// class Person{
// public $name;
// public function greet(){
// echo "Hello, my name is $this->name <br>";
// }
// }
// class Teacher extends Person{
// public $subject;
// public function displaySubject(){
// echo "I teach $this->subject <br>";
// }
// }
// $teacher=new Teacher();
// $teacher->name="Ram";
// $teacher->subject="math";
// $teacher->greet();
// $teacher->displaySubject();
class Person{
public $name;
public function greet(){
echo "Hello my name is $this->name <br>";
}
}
class Teacher extends Person{
public $subject;
public function displaySubject(){
echo "I teach $this->subject <br>";
}
}
$teacher=new Teacher();
$teacher->name="Greesma";
$teacher->subject="Web Technology II";
$teacher->greet();
$teacher->displaySubject();
?>