AdRock Posted February 13, 2009 Share Posted February 13, 2009 Just a couple simple questions on OOP Can you create a new instance of an existing class withing a function of a different class like so? and how would you call a function within the class in another function class MyClass { function MyFunction() { include_once("MyOtherClass.php"); $myvar = & new MyOtherClass(); //how to call MyOtherFunction() here } function MyOtherFunction() { //code for function } } Quote Link to comment https://forums.phpfreaks.com/topic/145076-couple-questions-on-oop/ Share on other sites More sharing options...
.josh Posted February 13, 2009 Share Posted February 13, 2009 class something { function foo () { // do something } function bar () { $this->foo(); } } Quote Link to comment https://forums.phpfreaks.com/topic/145076-couple-questions-on-oop/#findComment-761282 Share on other sites More sharing options...
Maq Posted February 13, 2009 Share Posted February 13, 2009 Read the manual. It contains all the answers, these are not meant to be secrets. Quote Link to comment https://forums.phpfreaks.com/topic/145076-couple-questions-on-oop/#findComment-761294 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.