The seventh chapter (13) The Declaration and use of object-oriented detailed _ interface
Interface interface Name {All attributes must be constants, all methods must be abstract, all members must be public}
The function of an interface: is a specification.
Use the implements< Inheritance interface keyword when implementing an interface.
You can use an abstract class to implement some of the methods of an interface.
Use the class to implement all the methods in the interface.
Use instances of interfaces:
interface< declaration Interface Keywords > Ren1
{
Const xingming= "John";
function shuohua1 ();
function Shuohua2 ();
}
Interface Ren2 extends< interface inheritance interface can use inherited keywords > Ren1
{
function Shuohua3 ();
function shuohua4 ();
}
Interface Ren3{function shuohua5 ();}
Interface Ren4{function shuohua6 ();}
Class Ren5{function Shuohua7 () {echo "7777<br>";}}
Class Ren extends Ren5 implemenrs< inherits the interface's keywords, you must first inherit the classes and inherit the interfaces, you can inherit multiple interfaces at the same time > Ren2,ren3,ren4
{
function shuohua1 () {echo "1111<br>";}
function Shuohua2 () {echo "2222<br>";}
function Shuohua3 () {echo "3333<br>";}
function shuohua4 () {echo "4444<br>";}
function Shuohua5 () {echo "5555<br>";}
function Shuohua6 () {echo "6666<br>";}
< Complete all inherited abstract methods >
}
$r =new Ren (); echo ren::xingming. " <br> ";
$r->shuohua1 (); $r->shuohua2 (); $r->shuohua3 (); $r->shuohua4 (); $r->shuohua5 (); $r->shuohua6 (); $r->shuohua7 ();
Instance output results:
Zhang 31,111 2222 3333 4444 5555 6666 7777