如何在PHP中使用类名从扩展类中调用方法

时间:2019-05-02 12:19:23

标签: php class methods extended-properties

假设我有3个类和方法;

  

file1.php

class A
{
  public function insert()
   {
     /* some code to do something with DB */
   }
}
  

file2.php

需要file1.php

class B extends A
{
  public function sample()
   {
      /* doing something random */
   }
}
  

file3.php

需要file2.php

class C extends B
{
 public function something()
  {
   $this->insert();  //In here I want to use it like $this->A->insert(); OR $A->insert(); 
  }
}

0 个答案:

没有答案