#29378 [NoF->Csd]: foreach() doesn't work with arrays returned by __get
| From: | tony2001@php.net | Date: | Sat, 19 Mar 2005 07:38:41 +0000 |
| Subject: | #29378 [NoF->Csd]: foreach() doesn't work with arrays returned by __get | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-75510@lists.php.net to get a copy of this message | ||
ID: 29378
Updated by: tony2001@php.net
Reported By: chernyshevsky at hotmail dot com
-Status: No Feedback
+Status: Closed
Bug Type: Zend Engine 2 problem
Operating System: Windows 2000
PHP Version: 5.0.0
New Comment:
Ok, marking it as closed.
Previous Comments:
------------------------------------------------------------------------
[2005-03-18 17:38:52] jrhernandez05 at gmail dot com
I have tried the original reproduce code using the latest PHP snapshot,
and have also tried it using some similar code I'm using in my
application, and it's working fine now! My environment is Windows 2000
using Apache2.
------------------------------------------------------------------------
[2005-03-14 01:00:20] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2005-03-06 20:52:40] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
------------------------------------------------------------------------
[2005-02-11 15:42:50] l0cky at jolt dot co dot uk
The simplest solution I have is
//Copy works
foreach($array = $object->array as $element)
{
print($element);
}
However, if you want to access the array elements by reference instead
of copy, then you're in trouble.
Even this produces the same error:
$array_ref =& $object->array;
------------------------------------------------------------------------
[2004-10-25 23:14:57] benneh at gmail dot com
I've just run into this problem, here is my test case
Testcase:
---------
class Language {
private $lang_bits = array();
public function __get($lang_bit) {
global $$lang_bit;
if(!isset($this->lang_bits[$lang_bit])) {
$this->lang_bits[$lang_bit] = $$lang_bit;
}
return $this->lang_bits[$lang_bit];
}
}
$page = array('bla' => 'xyz');
$lang = new Language;
foreach($lang->page as $lang_key => $lang_bit) {
echo $lang_key.' => '.$lang_bit;
}
Expected Results :
------------------
bla => xyz
Actual Results :
----------------
Fatal error: Cannot access undefined property for object with
overloaded property access
Just confirming its presence in 5.0.2 WinXP SP2 Apache 1.3.31
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/29378
--
Edit this bug report at http://bugs.php.net/?id=29378&edit=1