#37882 [Com]: overloading array access
| From: | ois at oisnot dot com | Date: | Wed, 09 Apr 2008 07:56:43 +0000 |
| Subject: | #37882 [Com]: overloading array access | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-124108@lists.php.net to get a copy of this message | ||
ID: 37882
Comment by: ois at oisnot dot com
Reported By: php at bouchery dot com
Status: Open
Bug Type: Feature/Change Request
Operating System: all
PHP Version: 5.1.5CVS
New Comment:
AS has been specified in comments here:
http://no2.php.net/manual/en/language.oop5.overloading.php
I think this should be set with the __set overload not __get though.
Previous Comments:
------------------------------------------------------------------------
[2006-06-22 07:39:23] php at bouchery dot com
Description:
------------
I would like to overload array access like this
<?php
class MyClass {
private $parameters = array();
function __set( $name, $value, $key ) {
if( ! isset( $this->parameters[ $name ] ) ) {
$this->parameters[ $name ] = array();
}
$this->parameters[ $name ][ $key ] = $value;
}
}
$object = new MyClass;
$object->a[ 'x' ] = 'value';
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37882&edit=1