php 中 interface的作用
interface IA{
public function foo();
}
class A implements IA{
public function foo(){
echo "A.foo ";
}
public function bar(){
echo "A.bar ";
}
}
class B{
public function foo(){
echo "B.bar ";
}
public function notBar(){
echo "B.notBar ";
}
}
//请注意这里的限制
function faint(IA $f){
$f->foo();
}
//这行可用
faint(new A);
//这行报错
faint(new B);