Hi,

write $this->items[$id] instead of $this->$items[$id]

bye
Wieger

Stefan Kostopoulos wrote:
> 
> 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);
> 
> ?>
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
Wieger Uffink
tel: +31 20 428 6868
fax: +31 20 470 6905
web: http://www.usmedia.nl

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to