total confusion about references

From: Date: Mon, 07 Feb 2000 12:46:08 +0000
Subject: total confusion about references
Groups: php.version4 
Request: Send a blank email to php-version4+get-9906@lists.php.net to get a copy of this message
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 the program below is (stupid) simple, but it does not work. the member-function Self(&$item) should return a reference to itself. but, as one can see, it returns a copy of itself: <? class Item { var $data; function Item() { $this->data=1; } function Self(&$item) { $item = &$this; } } $items[] = new Item; $items[] = new Item; $items[] = new Item; foreach($items as $item) echo $item->data, "<br>"; $itemkeys = array_keys($items); foreach($itemkeys as $itemkey) { $items[$itemkey]->Self($i); $i->data = 2; }; foreach($items as $item) echo $item->data, "<br>"; ?> am i wrong? eike stepper -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 6.0.2i iQA/AwUBOJ6weKxtuIvQ9KcmEQLwmwCg32x+vC/EK93Yfa9S6NZZErMD59oAn2kL 5gLhXqFyX5n1sErOnXAibfok =5pnG -----END PGP SIGNATURE-----

« previous php.version4 (#9906) next »