Home >Backend Development >PHP Tutorial >How to implement a single interface in php_PHP tutorial
This article describes the implementation method of php single interface. Share it with everyone for your reference. The specific implementation method is 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
|
<🎜>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 the interface { echo "Test"; } } ?> |