lilmer Posted May 31, 2013 Share Posted May 31, 2013 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? Quote Link to comment https://forums.phpfreaks.com/topic/278628-how-to-call-to-method-from-other-class-at-the-same-time/ Share on other sites More sharing options...
mac_gyver Posted May 31, 2013 Share Posted May 31, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/278628-how-to-call-to-method-from-other-class-at-the-same-time/#findComment-1433394 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.