This article describes the implementation method of multiple interfaces in php. Share it with everyone for your reference. The details are as follows:
?
2 3 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
|
<🎜>interface staff_i1 //Interface 1<🎜> <🎜>{<🎜> <🎜>function setID($id);<🎜> <🎜>function getID();<🎜> <🎜>}<🎜> <🎜>interface staff_i2 //Interface 2<🎜> <🎜>{<🎜> <🎜>function setName($name);<🎜> <🎜>function getName();<🎜> <🎜>}<🎜> <🎜>class staff implements staff_i1, staff_i2 //Interface implementation<🎜> <🎜>{<🎜> <🎜>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() { echo "Test"; } } ?> |