Re: Method inheritance and parent classes

From: Date: Fri, 04 Aug 2006 19:59:38 +0000
Subject: Re: Method inheritance and parent classes
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-25202@lists.php.net to get a copy of this message
On Fri, August 4, 2006 11:46 am, Christian Weiske wrote: > I recently had a problem that could be solved, but in an ugly way: > Class B extended Class A. Both classes define a method with the same > name. B called A's constructor, and A called $this->method(). This > executed B::method(), not A::method() as you would expect it. Most OOP people expect it to run B::method() That's rather the whole point of inheritence and subclasses. If you need to override it, you might be able to use A::method()... Though the OO purists have made that illegal now, I think. :-; There may be some kind of get_method() function on a class that you could use like: $function = get_method('A', 'method'); user_call_func(array($this, $function)); -- Like Music? http://l-i-e.com/artists.htm

« previous php.internals (#25202) next »