note 17289 deleted from keyword.parent by jimw

From: Date: Tue, 18 Dec 2001 22:58:47 +0000
Subject: note 17289 deleted from keyword.parent by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-23304@lists.php.net to get a copy of this message
For al@humantouch.de : actually there is a way : class test { function test1(){ echo "parent:test1";} function test2(){ echo "parent:test2"; test::test1(); // do not use $this here } } class sub extends test { function test1(){ echo "sub:test1";} function test2(){ echo "sub:test2"; parent::test2(); } } $a = new sub(); $a->test2(); /* returns: sub:test2 parent:test2 parent:test1 */ However itsbruce@netscape.net is right to point out that the default behavior is what you most probably expect : Think about class SortAlgorithms{ function max($a,$b){ /* default to integer comparison in base class*/ } function firstAlgorithm($myarray){ /* some loop */ $max = $this->max($a, $b); //etc ... } } Class SortStrings extends SortAlgorithms{ function max($a, $b){ /*some string comparison*/ } // that's all } Now when you execute any algorithm, which compare function do you expect in the SortStrings class ? Ivan

« previous php.notes (#23304) next »