代码改变世界

php接口 多态

2010-09-29 16:30  LvSir  阅读(204)  评论(0编辑  收藏  举报

<?php
interface p1{
public function show();

}
class p1_1 implements p1{
public function show(){
echo "dddd";
}
}
class p1_2 implements p1{
public function show(){
echo "eee";
}
}
class t1 extends p1_1{
public function show(){
echo "ttttttt";
}
}
function show(p1 $obj)
{
$obj->show();
}
$pp1=new p1_1();
$pp2=new p1_2();

show($pp1);
?>