interface Father{
public function write()
}
class Son implements Father{
public function write()
{
echo '儿子写字';
}
}
class Daughter implements Father{
public function write()
{
echo '女儿写字';
}
}
class Index{
public function son()
{
bind('son', 'Son');//第二个参数是son类的命名空间
$son = app('son');
var_dump($son->write());//打印出'儿子写字'
}
public function daughter()
{
bind('daughter', 'Daughter');//第二个参数是daughter类的命名空间
$daughter= app('daughter');
var_dump($daughter->write());//打印出'女儿写字'
}
}
网友评论