inheritance - php multiple derived and parallel inherited classes -
for example wan't make "base" class, , extend as possible, , make super class have extended methods.
class base { private $name; public function __construct($name) { $this->name=$name; } public function getname() { return $this->name; } } class extenda extends base { private $surname; public function __construct($surname) { $this->surname=$surname; } public function getsurname() { return $this->surname; } } class extendb extends base { private $lastname; public function __construct($lastname) { $this->lastname=$lastname; } public function getlastname() { return $this->lastname; } } class maximal ??? { .... ??? } $object=new maximal('name','surname','lastname'); $object->getname(); // name base class $object->getsurname(); // surname extenda class $object->getlastname(); // lastname extendb class
this possible if follow line-by-line inheritance a, b ext a, c ext b. if wan't parallel or order of extends unknown? maybe need use autoload?
@marc b
php not support multiple inheritance.
but real solution create code psr-4 - style , using autoload (composer or bootstrap style).
and can create lot of expendable staff.
also inheritance can "visually" changed static methods.
Comments
Post a Comment