How to implement multiple interfaces in php_PHP tutorial

WBOY
Release: 2016-07-13 09:49:07
Original
731 people have browsed it

How to implement multiple interfaces in php

This article describes the implementation method of multiple interfaces in php. Share it with everyone for your reference. The details are 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

35

36

37

interface staff_i1 //接口1

{

function setID($id);

function getID();

}

interface staff_i2 //接口2

{

function setName($name);

function getName();

}

class staff implements staff_i1, staff_i2 //接口的实现

{

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";

}

}

?>

1

2 3

45 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
<🎜>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"; } } ?>
I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/1020290.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1020290.htmlTechArticleHow to implement multiple interfaces in PHP This article describes how to implement multiple interfaces in PHP. Share it with everyone for your reference. The details are as follows: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template