PHP does not support multiple inheritance. This is the same for Java cept java has a workaround. Java allows you to implement multiple classes using something like :
class A extends B implements C
{
//
}
anyways I was looking around to see if PHP does anything like this but couldn't find anything. So I came up with my own workaround that allows you to implement multiple classes into one so you can access any of the methods or properties of any implemented classes.
Any questions or any ideas on how to improve this code?
Jeff
===========================================
<?PHP
class Base
{
function Base($val=null)
{
// Test for additional classes to instantiate
if($val != null)
{
// loop through class names and instantiate each class
for($i=0;$i<count($val);$i++)
{
// create object variable
$implement = $val[$i];
// store the object in a variable with the same name
// as the object, hence the $implement = $val[$i[;
$this->$implement = new $val[$i];
}
}
}
function draw()
{
return null;
}
}
class MeetingOfMinds extends Base
{
function meetHere()
{
print "I am the base class\n";
// must each object will be stored in a
print "" . $this->ImpOne->now();
print "" . $this->ImpTwo->now2();
}
}
class ImpOne
{
function now()
{
return "I am the the first implementation of another class\n";
}
}
class ImpTwo
{
function now2()
{
return "I am the the second implementation of still another class";
}
}
$circle = new MeetingOfMinds(array("ImpOne","ImpTwo"));
echo $obj = $circle->meetHere();
?>