|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-12-04 10:54 UTC] tony2001@php.net
[2006-12-04 10:54 UTC] tony2001@php.net
[2006-12-04 11:21 UTC] denis at edistar dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 04:00:01 2025 UTC |
Description: ------------ Php 5.2 raises a notice when i try to read an overloaded property using foreach construct. The foreach works correctly, so I don't think the warning should be raised. Otherwise the foreach should not work (as don't work reset, next, current and other array functions). Thank you, Denis Reproduce code: --------------- class a { private $myArr; public function __construct() { $this->myArr = array('1','2','3','4'); } public function __get($p) { if($p == 'myArr') { return $this->myArr; } } } $myObj = new a(); foreach($myObj->myArr as $value) { echo "myValue: " . $value."\n"; } Expected result: ---------------- myValue: 1 myValue: 2 myValue: 3 myValue: 4 Actual result: -------------- Notice: Indirect modification of overloaded property a:: $myArr has no effect in /tmp/test.php on line 21 myValue: 1 myValue: 2 myValue: 3 myValue: 4