ID: 47567
Updated by: [email protected]
Reported By: vyk2rr at gmail dot com
-Status: Open
+Status: Assigned
Bug Type: Scripting Engine problem
Operating System: Ubuntu 8.10
PHP Version: 5.2.9
-Assigned To:
+Assigned To: dmitry
New Comment:
Dmitry, you closed bug #33941 with comment "this is not fixable". Can
you explain why it isn't? :)
Previous Comments:
------------------------------------------------------------------------
[2009-03-04 23:55:47] vyk2rr at gmail dot com
Description:
------------
I can't add values to an array using __set($k, $v){...}
This look like this other bug http://bugs.php.net/bug.php?id=39449 but
is not the same
This is the same bug http://bugs.php.net/bug.php?id=33941 but is closed
:S
So I'm researching in the manual
(http://www.php.net/manual/en/language.oop5.overloading.php), but there
is nothing about it
Reproduce code:
---------------
<?php
class test {
private $vars = array();
public function __set($k, $v) { $this->vars[$k] = $v; }
public function showAll(){
echo "<pre>";
foreach($this->vars as $k=>$v){
echo "$k: ";
print_r($v); echo "<br />";
}
echo "</pre>";
}
}
$t = new test();
$t->a = 'one';
$t->b = 'two';
$t->c = array('one','two');
$t->c[] = 'three';
$t->c[] = 'four';
$t->d = array( );
$t->d[] = 'one';
$t->e = 'three';
$t->showAll();
?>
Expected result:
----------------
a: one
b: two
c: Array
(
[0] => one
[1] => two
[2] => three
[3] => four
)
d: Array
(
[0] => one
)
e: three
Actual result:
--------------
a: one
b: two
c: Array
(
[0] => one
[1] => two
)
d: Array
(
)
e: three
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47567&edit=1