note 40301 deleted from ref.overload by sobak

From: Date: Tue, 22 Nov 2016 03:49:18 +0000
Subject: note 40301 deleted from ref.overload by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-207448@lists.php.net to get a copy of this message
Note Submitter: josh at uncommonprojects dot com ---- One thing about __get is that if you return an array it doesn't work directly within a foreach... <?php class Foo { function __get($prop,&$ret) { $ret = array(1,2,3); return true; } } overload ('Foo'); //works $foo = new Foo; $bar = $foo->bar; foreach($bar as $n) { echo "$n \n"; } //doesn't work (bad argument to foreach) foreach($foo->bar as $n) { echo "$n \n"; } ?> for loops also work fine..

« previous php.notes (#207448) next »