general inheritance (not just) in PHP

Heyidfc

New Member
Let's have this class\[code\]class A { protected static function ident() { return "I am A"; } public static function say() { return "I say '".self::ident()."'!"; }}\[/code\]Then I need to extend class A and override the ident() like this\[code\]class B extends A { protected static function ident() { return "I am B"; }}\[/code\]Now when B::say(); is called, the result is I say 'I am A'. Is there any technique how to force it to produce I say 'I am B' \[code\]without overriding the say() method\[/code\]? (Please don't ask me why to do this, just trust me it is reasonable in my project)I believe it is possible via abstract class or interface, but I can not figure out how. If it is impossible in PHP, is there any language (except Haskell) which implements this feature?
 
Back
Top