1.抽象
如果有抽象方法,就需要使用abstract修饰,class也就需要用abstract修饰,没有方法体,当子类继承了抽象类,必须实现抽象类里面抽象方法。
2.接口
接口中所有方法都必须是抽象方法,不能定义变量,只能使用const修饰常量,而且类中所有成员必须有public访问权限,用interface修饰。实现用implements
interface xxx{
function test();
function test1();
}
abstract xxxx implements xxx{
function test(){}
}
class xx implements xxxx{
function test(){}
function test1(){}
}
3.多态
interface USB{
function run();
}
class Computer{
function userUSB($usb){
$usb->run();
}
}