I know PHP doesn't support multiple inheritance. But I need a way to use functions between two or more classes:
Code:
class one
{
function test1()
{
echo "one";
}
}
$one = new one;
class two
{
function test2()
{
$one->test1(); //This doesn't work
global $one;
$one->test1(); //Offcourse this does work
one::test1(); //This also works
// Using `class two extends one` also works, but what when i
// wan't to use functions from a third class? It can't be done.
}
}
I don't want to use 'global' in each function to make the class global. I prefer not to use one::test1(), because i wan't to keep working with objects. Although when there aren't any solutions, i can use it. Like i said before using `extends` isn't an option.
I also heard some people about using interfaces. But when you use interfaces, you still need to define the functions in each class.
So how should i do a workaround for multiple inheritance in PHP?