My question is similar to Call function in function from another class PHP, but its answer does not work for me.
Basically here is what I want to do.
in 'a.php', I defined class A.
class A{ function ab(){} function cd(){} function ef(){} ... } in 'b.php', I would like to define class B that can call the function in class A. Here is what I put, but it seems not work.
class B{ function xy(){ require 'a.php'; $a = new A(); $this->x = $a->ab(); $this->y = $a->cd(); return $a->ef(); } } Can anyone point me to the right direction? Thanks
========
UPDATE: to make my question more clear I made another example.
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; } }
class Btoclass Aand you can use those methods defined inclass A