我的问题类似于Call function in function from another class PHP,但它的答案对我不起作用。
基本上这就是我想要做的。
在'a.php'中,我定义了A类。
class A{
  function ab(){}
  function cd(){}
  function ef(){}
  ...
}
在'b.php'中,我想定义可以调用A类中的函数的B类。这是我放的,但它似乎不起作用。
class B{
  function xy(){
    require 'a.php';
    $a = new A();
    $this->x = $a->ab();
    $this->y = $a->cd();
    return $a->ef();
  }
}
谁能指出我正确的方向?谢谢
========
更新:为了让我的问题更清楚,我举了另一个例子。
class Person{
  function firstName(){return $this->firstName;}
  function lastName() {return $this->lastName;}
  function address()  {return $this->address;}
  ...
}
class Car{
  function ownerInfo(){
     $owner = array();
     require 'person.php';
     $p = new Person($this->ownerID);
     $owner['firstname'] = $p->firstName();
     $owner['lastname']  = $p->lastName();
     $owner['address']   = $p->address();
     //I am sure the data is there, but it returns nothing here
     return $owner;  
  }
}