Can anybody explain me why the following code does not work? I try to invoke a method on an 'indirect' object, that is, an object returned by the method of an object.
This may sound cryptic but I think the code clarifies what I want to do.
<?
class element {
var $name="";
function element () {
$this->name="Test";
}
}
class struct {
var $element;
function struct() {
$this->element = new element;
}
function getElement () {
return $this->element;
}
}
$stru = new struct;
$el = $stru->getElement();
print $el->name; // prints 'Test';
print $stru->getElement()->name; // generates parse error
?>