Classes and arrays
| From: | Stefan Kostopoulos | Date: | Tue, 08 May 2001 19:31:16 +0000 |
| Subject: | Classes and arrays | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-51965@lists.php.net to get a copy of this message | ||
Hi!
Can anybody explain to me why this script outputs:
oneone
instead of:
zeroone
???????????
Thanks,
stefan
<?
class Cart {
var $items; // Items in our shopping cart
function add_item ($id,$text) {
$this->$items[$id] = $text;
}
function output($id){
echo $this->$items[$id];
}
}
$c = new Cart;
$c->add_item(0,"zero");
$c->add_item(1,"one");
$c->output(0);
$c->output(1);
?>