abstract:<?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); ?>
/**
* 實現(xiàn)依賴注入的方式:
* 1.構造方法中實現(xiàn)
* 2.普通方式中實現(xiàn) ( 本例中使用的是這種方法)
*/
Correcting teacher:查無此人Correction time:2019-07-11 13:29:06
Teacher's summary:完成的不錯。依賴注入現(xiàn)在很流行,多了解。繼續(xù)加油