Jump to content

How to call to method from other Class at the same time


lilmer

Recommended Posts

I've got a class method that is working fine on my localhost but when I included on the website im working on it aint working, and I see that the site only requires static call.

I use to call like this, and this is working fine:

$result = $this->Class->method(0);

$result->methodFromAnotherClass();

But on the modified framework that right now I'm using I ain't allowed to use that kind of calling. It must be a static call so I use

$result = Class::method(0);

but when I use to call the other method like:

$result->methodFromAnotherClass();

It give's me an error.

Anyone can suggest how to do it?

Link to comment
Share on other sites

if Class::method(0); returns an instance of some result class, which it should so that you can have more than one of them at any time, then using $result->methodFromAnotherClass(); should work.

 

However, since you didn't post the error you got that would have given us actual information about why it didn't work, you are pretty much on you own with that problem.

 

if your question is instead how would you convert $result->methodFromAnotherClass() to a static call, that all depends on what the code is doing. you may need to completely rewrite it to allow for multiple sets of stored properties to support multiple instances of it.

 

in general, using static methods/properties should be avoided, not embraced.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.