Let's propose we have the following classes, and the following code:
class ParentClass {
public $x;
public $child;
public function __construct($x) {
$this->x=$x;
$this->child=new ChildClass();
}
}
class ChildClass extends ParentClass {
public function __construct() {
}
public function tellX() {
echo $this->x;
}
}
$parent1=new ParentClass('test');
$parent2=new ParentClass('test2');
echo $parent1->child->tellX();
echo "<BR>";
echo $parent2->child->tellX();
This outputs two empty lines for me. Is there any possibility, to create a new object(objChild), inside of an object(objParent), and access the non-static properties of objParent from objChild?