Scope of variable in Class

From: Date: Tue, 07 Nov 2000 03:32:55 +0000
Subject: Scope of variable in Class
Groups: php.general 
Request: Send a blank email to php-general+get-24045@lists.php.net to get a copy of this message
Suppose I have a class: class Cart {
      var $items;
      function add_item ($num) {
        $this->items = $num;
        }
} I can access (ie. print) $items by doing: $myCart = new Cart; echo $myCart->items; My question: is there any way so that someone can NOT access $items? in order words, make $items a PRIVATE variable for the class only? Thanks Reuben D. Budiardja

« previous php.general (#24045) next »