Hi everybody, sorry i don't know how to title this topic, and that's why i was not able to search for an answer on google or here in the forums so i thought i should go ahead and post this question.
i have class A and class B, class B will be initiated from within class A and it will be assigned to a property of class A so calling any method in class be will be like this:
$A->B->method();
but while I'm inside class B i might want to access a property from class A! using this will refer to class B itself! what can i do about that? of course using "parent" has nothing to do with this cos B does not inherit class A it was just initiated inside it.
here is an example code:
class classOne{
var $classTwo;
function __construct(){
$this->classTwo = new classTwo;
}
function testOne(){
return "HiOne";
}
}
class classTwo{
function testTwo(){
return ????->testOne;
}
}
$class_one = new classOne;
echo $class_one->classTwo->testTwo();
how can i access testOne from within testTwo? or this is not possible?
well so far all i can do is doing like this
echo $class_one->classTwo->testTwo($class_one);
so if i pass the class object by reference and use it there it would be possible but that's not what i am looking for.
so if there is anyway to achieve this, please let me know.
Thanks