|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2005-03-03 11:51 UTC] helly@php.net
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 10:00:02 2025 UTC | 
Description: ------------ When extending the SPL ArrayIterator class and overloading the offsetGet/offsetSet methods, it appears that neither of the overloaded methods are called when accessing the object like an array (ie $myObject['index']) Reproduce code: --------------- <?php class myArray extends ArrayIterator { public function __construct ($array = array ()) { parent::__construct ($array); } public function offsetGet ($index) { echo 'offsetGet called'; return parent::offsetGet ($index); } public function offsetSet ($index, $newval) { echo 'offsetSet called'; return parent::offsetSet ($index, $newval); } } $myArray = new myArray (); $myArray->offsetSet ('one', 'one'); echo $myArray->offsetGet ('one'); $myArray['two'] = 'two'; echo $myArray['two']; ?> Expected result: ---------------- offsetSet called offsetGet called one offsetSet called offsetGet called two Actual result: -------------- offsetSet called offsetGet called one two