really simple, I guess, but why does the following not work? I assume this is a matter of visibility when class2 is not displayed inside class1. Yes, I get the error "Calling a member function on a non-object."
class class1 { function func1() { $class2->func3(); } function func2() { $this->func1(); } } class class2 { function func3() { echo "hello!"; } } $class1 = new class1(); $class2 = new class2(); $class1->func1;
If anyone can help me, I would be very grateful. I searched around for a while, but I have many examples of others trying to create new classes inside other classes and the like, and not for this particular problem.
You would be right in thinking that I do not do much with classes!
source share