Posted: Mon Jul 10, 2006 8:32 am
You guys may want to know that the two classes will create an infinite recursion in class creations. PHP will notice and stop it.
Each respective class creates an instance of the other. This starts the recusion. As each one is created, the other must be created too.
Use a basic composition model instead.
The problem is, the original concept promotes really nasty coupling. If they are that integrated, you may want to consider building them together or rethinking their interactions more carefully.
Each respective class creates an instance of the other. This starts the recusion. As each one is created, the other must be created too.
Use a basic composition model instead.
Code: Select all
<?php
class Test
{
private $testing;
public function __construct ()
{
}
public function setTesting ($testing)
{
$this->testing = $testing;
}
}
class Testing
{
private $test;
public function __construct ()
{
$this->test = new Test();
}
public function setTest ($test)
{
$this->test = $test;
}
}
$test = new Test();
$testing = new Testing();
$test->setTesting($testing);
$testing->setTest($test);
?>