When I do the following:
class AA {
public $a = '';
function __construct() {
$this->a = new BB();
}
}
class BB {
public $b = '';
function __construct() {
$this->b = new AA();
}
}
I get Fatal error: Allowed memory size of X bytes exhausted.
Is it even possible to achieve what I am trying to do above?
What am I trying to accomplish:
Let's say I have objects:
Universe:
Galaxy
Galaxy
Galaxy
Galaxy:
Blackhole
Star
Star
Star
Star
Blackhole:
Whitehole
Whitehole:
Universe
Then, Universe in white hole is same as big universe and it would continue as above, recursively.
createBlackhole()method in your galaxy,createWhitehole()in your backhole class etc. the call the when needed. because galaxies does not exist for creating blackholes, or blackholes does not only exist to create whiteholes. so do not make such abstraction. if one day you'll make universe to be your compiler, be sure, it would also spit that error.