Re: [PHP4BETA] Class method calling same method in parent

From: Date: Wed, 10 May 2000 23:28:27 +0000
Subject: Re: [PHP4BETA] Class method calling same method in parent
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-14804@lists.php.net to get a copy of this message
In your base class (class X), have a base function (call it super_foo()) which will be called by the X::foo(), as follow: class X { function foo() { super_foo(); } function super_foo() { $this->bar(); } }; Then, in the derived class (class Y), it can call the super_foo() directly. class Y extends X { function foo() { $this->super_foo(); $this->baz(); } }; Hope that helps. Cheers, Ly Vuong --- Jeff Dickey wrote: > > I need to be able to have a class which extends another class, and have a > method in that class be able to call the method with the same signature in > the parent class. Something like: > > class X { > function foo() { $this->bar(); } > // ... > }; > > class Y extends X { > function foo() { $super()->foo(); $this->baz(); } > // ... > }; > > This is trivial in all the other OO languages I use (Ada, C++, Java). Can > someone point me to how to do it in PHP? Many thanks.... > > Jeff > > -------- > Jeff Dickey > Title Irrelevant > Lariat Software, Inc. > +1 206 695 5757 - voice > +1 206 652 4736 - fax > mailto:jdickey@lariat.com > mailto:jeff_dickey@hotmail.com - personal email > mailto:4252603103@messaging.sprintpcs.com - pager > "If you can't reach me through all these, one of us is probably dead" > > -- > PHP 4.0 Beta Mailing List <http://www.php.net/version4/> > To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net > For additional commands, e-mail: php4beta-help@lists.php.net > To contact the list administrators, e-mail: php4beta-admin@lists.php.net

« previous php.version4 (#14804) next »