note 33321 modified in keyword.extends by danbrown

From: Date: Wed, 17 Jun 2009 19:05:19 +0000
Subject: note 33321 modified in keyword.extends by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-157030@lists.php.net to get a copy of this message
Just a quick note to make things more clear : while multiple inheritance is not allowed, several levels of single inheritance ARE ALLOWED indeed. Just test this example : <?php class A { var $name='A'; function disp() { echo $this->name; } } class B extends A { var $name='B'; } class C extends B { var $name='C'; } $truc = new C() ; $truc->disp(); // Will output C ?> This is especially important to keep in mind while building a huge object hierarchy. for example : +GenericObject ->+ Person ->->Employee ->+Computer ->->+WorkStation ->->-> PPC ->->-> Intel ->->+Server ->->->LDAPServer ->->->IntranetWebServer .. and so on. Multiple level hierarchy relationship are possible in a tree-like structure (each child has one and only one parent, except for the root object). --was-- Just a quick note to make things more clear : while multiple inheritance is not allowed, several levels of single inheritance ARE ALLOWED indeed. Just test this example : <? class A { var $name='A'; function disp() { echo $this->name; } } class B extends A { var $name='B'; } class C extends B { var $name='C'; } $truc = new C() ; $truc->disp(); // Will output C ?> This is especially important to keep in mind while building a huge object hierarchy. for example : +GenericObject ->+ Person ->->Employee ->+Computer ->->+WorkStation ->->-> PPC ->->-> Intel ->->+Server ->->->LDAPServer ->->->IntranetWebServer .. and so on. Multiple level hierarchy relationship are possible in a tree-like structure (each child has one and only one parent, except for the root object). http://php.net/manual/en/keyword.extends.php

« previous php.notes (#157030) next »