Access Outer Classes methods
Posted: Mon Dec 08, 2008 1:38 pm
Hi
I have searched for hours trying to find the answer to this and it seems such an obvious question, I can't believe I haven't found the answer.
If I have 2 classes, and one class is created inside the other, how do I access the methods and variables of the outer class from the inner class. A bit of code probably explains it better
class Outer{
public function __construct(){
$inner = new Inner();
}
function moo(){
print "Moo Moo";
}
}
class Inner{
//How do I call Outer's moo() from here?
}
Thanks in Advance
Cheers
Rob
I have searched for hours trying to find the answer to this and it seems such an obvious question, I can't believe I haven't found the answer.
If I have 2 classes, and one class is created inside the other, how do I access the methods and variables of the outer class from the inner class. A bit of code probably explains it better
class Outer{
public function __construct(){
$inner = new Inner();
}
function moo(){
print "Moo Moo";
}
}
class Inner{
//How do I call Outer's moo() from here?
}
Thanks in Advance
Cheers
Rob