PHP 依赖注入及解读
//依赖注入是应用于一个类的实例化需要依赖另外一个类的场景
//Person依赖于Student类,Student类注入到Person
  class Person{
        public function teach($obj){
              return $obj->study();
        }
  }
  class Student{
    public function study(){
              return 123;
        }
  }
  public function personTest(){
        $p = new Person();
        $s = new Student();
        echo $p->teach($s);
  }
 
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号