Under PHP5:
Can a class implement more than one interface:
class SomeClass implements Interface1, Interface2
{
}
Can a class implement AND extend another class?
class SomeClass extends AnotherClass implements Interface1
{
}
From my understanding, PHP5 does not allow multiple inheritance. Thus use of one of the techniques above is needed.Originally posted by kkobashi
Under PHP5:
Can a class implement more than one interface:
class SomeClass implements Interface1, Interface2
{
}
IIRC, I read somewhere that this was possible.... easiest way to find out is to try.
Can a class implement AND extend another class?
class SomeClass extends AnotherClass implements Interface1
{
}
From my understanding, PHP5 does not allow multiple inheritance. Thus use of one of the techniques above is needed. See previous note PHP5 supports single inheritance and multiple implementations, at the same time.
class bar extends foo implements moo, doo, boo {
}
Not sure what that has to do with multiple inheritance though?kkobashi, you are right, PHP doesn't support multiple inheritance. I think you're confusing inheritance and interfaces. Interfaces are used to get around the multiple inheritance problem, which sometimes limits you from giving certain objects the functionality they need.
Interfaces are used heaps in Java. But to be honest, I can't think of a useful purpose for them in PHP.Originally posted by BSTRhino
Interfaces are used heaps in Java. But to be honest, I can't think of a useful purpose for them in PHP. You can if($object instanceof InterfaceName)
<!-- m --><a class="postlink" href="http://www.phpbuilder.com/board/showthread.php?s=&threadid=10284617">http://www.phpbuilder.com/board/showthr ... d=10284617</a><!-- m -->
Can a class implement more than one interface:
class SomeClass implements Interface1, Interface2
{
}
Can a class implement AND extend another class?
class SomeClass extends AnotherClass implements Interface1
{
}
From my understanding, PHP5 does not allow multiple inheritance. Thus use of one of the techniques above is needed.Originally posted by kkobashi
Under PHP5:
Can a class implement more than one interface:
class SomeClass implements Interface1, Interface2
{
}
IIRC, I read somewhere that this was possible.... easiest way to find out is to try.
Can a class implement AND extend another class?
class SomeClass extends AnotherClass implements Interface1
{
}
From my understanding, PHP5 does not allow multiple inheritance. Thus use of one of the techniques above is needed. See previous note PHP5 supports single inheritance and multiple implementations, at the same time.
class bar extends foo implements moo, doo, boo {
}
Not sure what that has to do with multiple inheritance though?kkobashi, you are right, PHP doesn't support multiple inheritance. I think you're confusing inheritance and interfaces. Interfaces are used to get around the multiple inheritance problem, which sometimes limits you from giving certain objects the functionality they need.
Interfaces are used heaps in Java. But to be honest, I can't think of a useful purpose for them in PHP.Originally posted by BSTRhino
Interfaces are used heaps in Java. But to be honest, I can't think of a useful purpose for them in PHP. You can if($object instanceof InterfaceName)
<!-- m --><a class="postlink" href="http://www.phpbuilder.com/board/showthread.php?s=&threadid=10284617">http://www.phpbuilder.com/board/showthr ... d=10284617</a><!-- m -->