arrays of objects
| From: | Stephanie Wehner | Date: | Fri, 04 Feb 2000 00:26:11 +0000 |
| Subject: | arrays of objects | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-15180@lists.php.net to get a copy of this message | ||
Hi,
Is this a known 'feature' or a bug ? If I have an array of objects and I want
to change some variable in one of them, then this seems to work only temporarily:
<?
class Foo{
var $test = "test1";
function assignTest($string) {
$this->test = $string;
}
}
$testing = new Foo;
echo "$testing->test<br>";
$some_array[0] = $testing;
$tmp = $some_array[0];
$tmp->assignTest("test2");
echo "$tmp->test<br>";
$tmp2 = $some_array[0];
echo "$tmp2->test<br>";
?>
This will print test1,test2,test1 . This would not be that annoyind cause I can
do $some_array[0]->assignTest("foo") as well. However if I would do that in a class
then things become a problem since I can't do $this->foo->bar() for example.
Is there a way how this can still be done ? Or is it simply a bug ?
bye,
@rak
----------------------------<> _@r4k.net <>-----------------<> FreeBSD <>---
"I had to hit him -- he was starting to make sense."