I was just wondering if it is possible to create a new object inside of a different class.
class One { //constructor function One { $this->two = new Two; $this->test = $this->two->test(); } }
Can you do that? If so is that how you do it?
Yes, and you do it just like you'd create it outside of the class:
this: $this->two = new Two(); equals this: $two = new Two();
It should work, but I think there are some php "features" that might make it not work correctly. If instantiating the object in the constructor doesn't work, add another method that's called after the constructor returns.