-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.php
More file actions
58 lines (32 loc) · 1 KB
/
interface.php
File metadata and controls
58 lines (32 loc) · 1 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
//Interface is a collection of abstract methods without body--
interface Inter {
function getInterName();
function getInterDate();
}
//Any class implementing itnerface must provide body for all methods of interface
class Test implements Inter {
function getInterName() {
echo 'provided body for interface method getInterName() <br />';
}
function getInterDate() {
echo 'provided body for interface method getInterDate() <br />';
}
}
$test = new Test;
$test->getInterName();
$test->getInterDate();
// Abstract class is collection of methods with body or without body
Abstract class Abs {
abstract function getAbsName();
function getAbsDate() {
}
}
// Any class extending abstract class must provide body for all the abstract methods presebt in the class
class Test2 extends Abs {
function getAbsName() {
echo 'provided body for abstract class method getAbsName() <br />';
}
}
$test2 = new Test2;
$test2->getAbsName();