note 40301 added to ref.overload
| From: | josh at uncommonprojects dot com | Date: | Fri, 27 Feb 2004 23:45:49 +0000 |
| Subject: | note 40301 added to ref.overload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-65909@lists.php.net to get a copy of this message | ||
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..
----
Manual Page -- http://www.php.net/manual/en/ref.overload.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40301
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40301&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40301&report=yes
Search -- http://master.php.net/manage/user-notes.php