note 74945 modified in language.oop5.overloading by danbrown

From: Date: Fri, 14 Nov 2008 17:14:30 +0000
Subject: note 74945 modified in language.oop5.overloading by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-146541@lists.php.net to get a copy of this message
While playing a bit with the __call magic method I found you can not emulate implementing methods of an interface as you might think: <?php class Iteratable implements Iterator { public function __call($funcname) { if(in_array($funcname, array('current', 'next', /*...*/)) { //Redirect the call or perform the actual action } } } ?> Using this code you'll get a "class Iteratable contains abstract methods ..." fatal error message. You'll ALWAYS have to implement those routines by hand. --was-- While playing a bit with the __call magic method I found you can not emulate implementing methods of an interface as you might think: <? class Iteratable implements Iterator { public function __call($funcname) { if(in_array($funcname, array('current', 'next', /*...*/)) { //Redirect the call or perform the actual action } } } ?> Using this code you'll get a "class Iteratable contains abstract methods ..." fatal error message. You'll ALWAYS have to implement those routines by hand. http://php.net/manual/en/language.oop5.overloading.php

« previous php.notes (#146541) next »