multiple class inheritance
In PHP, is it possible to have multiple inheritance (by the nature of the PHP, not writting modification code)?
For example :
class a
{
public fun开发者_StackOverflowction foo();
}
class b
{
public function bar();
}
class c extends a, b
{
public function baz();
}
No. There's no real multiple inheritance in PHP and thats a good thing. See the other answers for alternatives.
Edit: By now, PHP supports Traits, of which one class can include more than one. They avoid the usual problems of multiple inheritance by throwing an error or requiring you to alias conflicting names.
class A extends B{
}
class B extends C{
}
class C{
}
精彩评论