note 78137 deleted from language.oop.constructor by ezyang

From: Date: Sat, 29 Sep 2007 18:07:26 +0000
Subject: note 78137 deleted from language.oop.constructor by ezyang
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-130929@lists.php.net to get a copy of this message
Note Submitter: Brent Reason: bad code ---- Another way to call the parent constructor without knowing the parent class, and without creating another method such as constructor(), you can just do this: class A { function A() { echo "Constructor for parent class called.<br>"; } } class B { function B() { // This calls the parent constructor ... eval ("self::" . get_parent_class($this) . "();"); // Then you can put subclass constructor stuff ... echo "Constructor for subclass called."; } }

« previous php.notes (#130929) next »