note 113376 added to language.oop5.paamayim-nekudotayim

From: Date: Thu, 03 Oct 2013 13:25:21 +0000
Subject: note 113376 added to language.oop5.paamayim-nekudotayim
Groups: php.notes 
Request: Send a blank email to php-notes+get-196456@lists.php.net to get a copy of this message
Just found out that using the class name may also work to call similar function of anchestor class. <?php class Anchestor { public $Prefix = ''; private $_string = 'Bar'; public function Foo() { return $this->Prefix.$this->_string; } } class MyParent extends Anchestor { public function Foo() { $this->Prefix = null; return parent::Foo().'Baz'; } } class Child extends MyParent { public function Foo() { $this->Prefix = 'Foo'; return Anchestor::Foo(); } } $c = new Child(); echo $c->Foo(); //return FooBar, because Prefix, as in Anchestor::Foo() ?> The Child class calls at Anchestor::Foo(), and therefore MyParent::Foo() is never run. ---- Server IP: 69.147.83.199 Probable Submitter: 195.1.219.162 ---- Manual Page -- http://php.net/manual/en/language.oop5.paamayim-nekudotayim.php Edit -- https://master.php.net/note/edit/113376 Del: integrated -- https://master.php.net/note/delete/113376/integrated Del: useless -- https://master.php.net/note/delete/113376/useless Del: bad code -- https://master.php.net/note/delete/113376/bad+code Del: spam -- https://master.php.net/note/delete/113376/spam Del: non-english -- https://master.php.net/note/delete/113376/non-english Del: in docs -- https://master.php.net/note/delete/113376/in+docs Del: other reasons-- https://master.php.net/note/delete/113376 Reject -- https://master.php.net/note/reject/113376 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#196456) next »