PHP : $this->methodcall() gives error and CalledClass:methodcall() works fine

ReginkaA

New Member
I am trying to call method \[code\]getDetails()\[/code\] from another class which in turns calls to methods from its own class(i.e, called class) and it does so by \[code\]$this->getAccount()\[/code\] and \[code\]$this->getAddress()\[/code\] and in called class we have methods like \[code\]$this->getAccount()\[/code\] and \[code\]$this->getAddress()\[/code\] function but when I call them I get fatal error message as call to undefined method, but when I try calling that method using \[code\]CalledClassName::getAddress()\[/code\] and \[code\]CalledClassName::getAddress()\[/code\] than it works fine.My question is that class which am calling(i.e, calledClass ) will always have use \[code\]$this->getAddress()\[/code\] and \[code\]$this->getAccount()\[/code\] as am getting this class information from other team and there are 3 teams that would be calling functions \[code\]getDetails()\[/code\] which would internally call \[code\]getAccount()\[/code\] and \[code\]getAddress()\[/code\] functions and so how should I deal with the issue of $this on myside when am calling \[code\]getDetails()\[/code\] function. Code Example\[code\]Calling Class:CalledClass::getDetails() // Call to getDetails function in CalledClassCalledClass::public function postalAddress(){ return array( 'addressId' => $address->addressId, 'city' => $address->city, 'country' => $address->country, 'postcode' => $address->postcode, 'stateOrProvince' => $address->stateOrProvince, 'street' => $address->streetName, 'streetNumber' => $address->streetNrFirst, 'streetSuffix' => $address->streetNrFirstSuffix );};public function getAddress(){ return $this->postalAddress();}public function setAccount($account){ $this->account = $account;}public function getAccount(){ return $this->find('account = 1311143','');} public function getDetails() { $data = http://stackoverflow.com/questions/2103127/array(); $data[$address] = $this->getAddress(); $data[$account] = $this->getAccount(); return $data; }\[/code\]So now using the above method it gives me error and so if am using \[code\]CalledClass::getAddress()\[/code\] and \[code\]CalledClass::getAccount()\[/code\] and it works fine but I cant chang e the code in the calledclass as am calling this function from another team. Any guidance or suggestions ?
 
Back
Top