Inheritance & overriding methods

From: Date: Thu, 11 Apr 2002 14:15:31 +0000
Subject: Inheritance & overriding methods
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-92576@lists.php.net to get a copy of this message
Hi, The subject says it all, really, I need to be able to override a superclass method AND also call the super's method in a way so that IN the super's method "$this" will refer to the original object, as follows: <?php Class A { function A () { // do some stuff... } function doit () { print (get_class ($this)); } } Class B extends A { function B () { // do some more stuff... } function doit () { // This is what I'd like to do... $super->doit (); print (get_class ($this)); } } $b = new B (); $b->doit (); ?> This should print "BB"; Now, in PHP we don't have "$super" to call the superclass' method. Is there a way around this? Renaming the functions is not an option. Grateful for any hints. Cheers, -Morten ------------------------------------------------------------------- Rayon Interactive AS http://www.rayon.no Morten Lerskau Rønseth mailto:morten.ronseth@rayon.no Karenslyst Allé 16d Tlf.: (47) 2213 5250 0278 Oslo Fax : (47) 2213 5260 Norway PGP fingerprint: F851 91B6 1D81 1409 8B62 3E14 5A60 65F8 5AF4 56AF

« previous php.general (#92576) next »