Php single interface Implementation Method
This example describes how to implement a single php interface. Share it with you for your reference. The specific implementation method is as follows:
?
|
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 |
<? Php
Interface staff_ I
{
Function setID ($ id );
Function getID ();
Function setName ($ name );
Function getName ();
}
Class staff implements staff_ I // This class is used to implement the staff_ I Interface
{
Private $ id;
Private $ name;
Function setID ($ id)
{
$ This-> id = $ id;
}
Function getID ()
{
Return $ this-> id;
}
Function setName ($ name)
{
$ This-> name = $ name;
}
Function getName ()
{
Return $ this-> name;
}
Function otherFunc () // This is a method that does not exist in an Interface
{
Echo "Test ";
}
}
?>
|
I hope this article will help you with php programming.