//\app\common\Temp $temp 触发依赖注入
//依赖注入就是将对象传递到方法中
public function getMothod(\app\common\Temp $temp){
//\app\common\Temp $temp等价于
//$temp =new \app\common\Temp;
$temp->setName('学习tp5.1');
echo $temp->getName();
}
依赖注入的理解
最新推荐文章于 2023-08-15 17:09:57 发布