note 49917 deleted from language.oop by danbrown

From: Date: Sat, 07 Nov 2009 19:03:24 +0000
Subject: note 49917 deleted from language.oop by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-162562@lists.php.net to get a copy of this message
Note Submitter: alberto dot delatorre at gmail dot com ---- If you have a class hierarchy as this: <?php abstract class A{ //construct ommited public function load(){ $this->_load(); } protected abstract function _load(); } class B extends A{ protected function _load(){ echo "loaded"; } } $b = new B(); $b->load(); ?> you encountered that you will have a 'calling an abstract method' in the line with '$this->_load'. To avoid this, just make another reference to $this and then call the method you'd want, this way: <?php abstract class A{ //construct ommited public function load(){ $aux_this=&$this; $aux_this->_load(); } protected abstract function _load(); } class B extends A{ protected function _load(){ echo "loaded"; } } $b = new B(); $b->load(); ?>

« previous php.notes (#162562) next »