Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 556563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:55:59+00:00 2026-05-13T11:55:59+00:00

I am trying to call method getDetails() from another class which in turns calls

  • 0

I am trying to call method getDetails() from another class which in turns calls to methods from its own class(i.e, called class) and it does so by

$this->getAccount() and $this->getAddress() and in called class we have methods like $this->getAccount() and $this->getAddress() function but when I call

them I get fatal error message as call to undefined method, but when I try calling that method using CalledClassName::getAddress() and

CalledClassName::getAddress() than it works fine.

My question is that class which am calling(i.e, calledClass ) will always have use $this->getAddress() and $this->getAccount() as am getting this class

information from other team and there are 3 teams that would be calling functions getDetails() which would internally call getAccount() and getAddress()

functions and so how should I deal with the issue of $this on myside when am calling getDetails() function.

Code Example

Calling Class:


CalledClass::getDetails() // Call to getDetails function in CalledClass


CalledClass::


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 = array();
     $data[$address] = $this->getAddress();
     $data[$account] = $this->getAccount();
     return $data;
    }

So now using the above method it gives me error and so if am using CalledClass::getAddress() and CalledClass::getAccount() 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 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:55:59+00:00Added an answer on May 13, 2026 at 11:55 am

    If the function you are trying to call from another class is static, you need to use the :: (scope resolution operator) to call on it. It is also the same way when trying to access static properties.

    Because static methods are callable without an instance of the object created, the pseudo-variable $this is not available inside the method declared as static.

    Taken from PHP: Static Keyword

    In the meantime for your method call to work without having the ability to modify the other member’s code is to use CalledClass::getAddress()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 285k
  • Answers 285k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Looking at the Railo source code, I see that railo.runtime.type.QueryImpl… May 13, 2026 at 4:46 pm
  • Editorial Team
    Editorial Team added an answer Running wireshark / tshark would be one way. Many proxies… May 13, 2026 at 4:46 pm
  • Editorial Team
    Editorial Team added an answer Did you remember to migrate the indexes from the larger… May 13, 2026 at 4:46 pm

Related Questions

I am trying to call a method I have written in C# from VBScript.
I am working with ASP.net. I am trying to call a method that exists
I am trying to export a Ruby framework via XML-RPC. However I am having
I am trying to create a class with two methods with the same name,
I am trying to create a custom CStatic control in vc++ and have a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.