摘要:<?php class Sport { public function whatslike() { return '这个运动不错';
<?php
class Sport
{
    public function whatslike()
    {
        return '这个运动不错';
    }
}
class Test
{
    public function showme(Sport $sport)
    {
        return '我会射箭'.$sport->whatslike();
    }
}
$sport = new Sport ();
$result = new Test ();
echo $result->showme($sport);
?>/**
 * 实现依赖注入的方式:
 * 1.构造方法中实现
 * 2.普通方式中实现 ( 本例中使用的是这种方法)
*/
						批改老师:查无此人批改时间:2019-07-11 13:29:06		
						
老师总结:完成的不错。依赖注入现在很流行,多了解。继续加油					
 
                 
 
 
  
            