Hey guys,
I've been developing an Object orented PHP solution and I need help really bad. What I need to know is:
1)How do you make a class that has another object as property by default, without instantiating the object in the constructor?
2) OR, if you instantiate the object in the contructor, how do you call the contructor from the classes child's child without crashing PHP?*
*for some reason calling the parents constructor from the child's child crashes PHP...But not from a child. here's an example:
class parentClass
{
var $r = "";
function parentClass()
{
$this->r = "hello";
}
}
class child extends parentClass
{
var $p = "";
function child()
{ $myParent = get_parent_class($this);
$this->$myParent();
$this->p = $this->r." world!";
}
}
class grandChild extends child
{
var $q = "";
function grandChild()
{ $myParent = get_parent_class($this);
$this->$myParent();
$this->q = $this->p." CRASH NOW!";
}
}
//this won't crash your server
$theClass = new child();
echo $theClass->p;
//this will crash PHP
//$theOtherClass = new grandChild();
//echo $theOtherClass->q;