#28129 [Opn->WFx]: Overloading [] -operators would be very userful

From: Date: Fri, 23 Apr 2004 20:58:03 +0000
Subject: #28129 [Opn->WFx]: Overloading [] -operators would be very userful
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-58679@lists.php.net to get a copy of this message
ID: 28129 Updated by: derick@php.net Reported By: niz at sci dot fi -Status: Open +Status: Wont fix Bug Type: Feature/Change Request PHP Version: 5.0.0RC1 New Comment: We're not going to overload any more operators, you can use SPL for this anyway. Previous Comments: ------------------------------------------------------------------------ [2004-04-23 19:27:55] niz at sci dot fi Description: ------------ I was developing own array class for php5 and result was not very usable because I can't overload [] -operator.. It's good that iteration is now in php5 but better overloading support is needed. It could work something like this: class xArray { private $data = array(0 => "first", 1 => "second"); function __index($key) { return $this->data[$key] } } $test = new xArray(); print($test[0]); // would print "first" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28129&edit=1

« previous php.bugs (#58679) next »