|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-04-14 23:03 UTC] shane@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
If a class is overloaded and it uses __call() the overloaded class cannot return anything from its methods. Example code: <?php class Foo { var $bar = 'barvalue'; function Foo() { } function getBar() { return($this->bar); } function printBar() { print($this->bar); return('foo'); } function getAny() { return('Any'); } function __call($method,$params,&$return) { $return=$method($params[0]); return(true); } } overload('Foo'); $f = new Foo(); print '$f->getBar(): ' . $f->getBar() . "\n"; print '$f->printBar(): '; print $f->printBar(); print "\n"; print '$f->bar: ' . $f->bar . "\n"; print '$f->getAny(): ' . $f->getAny() . "\n"; ?> output is: $f->getBar(): $f->printBar(): barvalue $f->bar: barvalue $f->getAny(): after removing the function __call() from the class it works as expected. Output is then: $f->getBar(): barvalue $f->printBar(): barvaluefoo $f->bar: barvalue $f->getAny(): Any