$a->b->c reference ?
Posted: Tue Apr 20, 2010 9:09 pm
Hello,
This is probably something simple, but I can not find an aswer to my question...
I define a class:
class myClass {
var $pointer;
};
Then I do the following:
$myClassRef = new myClass;
$myClassRef->pointer = new AnotherClass;
So far everything is good. Then when I do the following:
$x = $myClassRef->pointer;
echo $x->elementofAnotherClass;
everything is good.
If I try however something, which - to me - would be intuitive, that is:
echo $myClassRef->pointer->elementofAnotherClass;
I get a 'Catchable fatal error: Object of class System could not be converted to string in ...'.
My PHP version is 5.2.13 but this did not work in version 4.xx either.
Could somebody help me with this, please?
Thank you so much,
ZB21
This is probably something simple, but I can not find an aswer to my question...
I define a class:
class myClass {
var $pointer;
};
Then I do the following:
$myClassRef = new myClass;
$myClassRef->pointer = new AnotherClass;
So far everything is good. Then when I do the following:
$x = $myClassRef->pointer;
echo $x->elementofAnotherClass;
everything is good.
If I try however something, which - to me - would be intuitive, that is:
echo $myClassRef->pointer->elementofAnotherClass;
I get a 'Catchable fatal error: Object of class System could not be converted to string in ...'.
My PHP version is 5.2.13 but this did not work in version 4.xx either.
Could somebody help me with this, please?
Thank you so much,
ZB21