|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-09-09 20:34 UTC] johannes@php.net
[2005-09-09 21:14 UTC] stochnagara at hotmail dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 03:00:02 2025 UTC |
Description: ------------ I made a class which implements ArrayAccess. Then I try to use foreach on one of its array values and I get error "Objects used as arrays in post/pre increment/decrement must return values by reference" I've reduced the big code fragment to this small one: Reproduce code: --------------- <? class foo implements ArrayAccess { protected $params; public function offsetGet ($field) { return $this->params[$field]; } public function offsetExists ($field) { return isset ($this->params[$field]); } public function offsetUnset ($field) { unset ($this->params[$field]); } public function offsetSet ($field, $value) { $this->params[$field] = $value; } } $foo = new foo; foreach ($foo['options'] as $optionvalue => $optiontext) {} Expected result: ---------------- no errors Actual result: -------------- Fatal error: Objects used as arrays in post/pre increment/decrement must return values by reference in ... on line 161