thinkphp5.1中构造方法依赖注入

原创 2019-04-16 22:01:40 388
摘要://thinkphp5.1中构造方法依赖注入class Index{    protected $user;    public function __construct(User $user)    {        $this->user = $user;    } &

//thinkphp5.1中构造方法依赖注入

class Index{
   protected $user;
   public function __construct(User $user)
   {
       $this->user = $user;
   }

   public function hello()
   {
       return 'Hello,' . $this->user->name ;
   }

}

批改老师:查无此人批改时间:2019-04-17 09:14:03
老师总结:完成的不错。不过是不是代码不全,我没看到name,只看到调用了。继续加油。

发布手记

热门词条