Re: New to classes

From: Date: Sat, 24 May 2003 19:17:54 +0000
Subject: Re: New to classes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-148874@lists.php.net to get a copy of this message
Hi, First things first; classes in PHP version 4.x are nothing more than syntactic sugar for arrays, so basically you can't hide anything from a class to the outside world; so $myot->lot['something'] = $value; is perfectly legal and does what you wanted too. One piece of advice though; it's pointless to use classes like that. It breaks the idea of encapsulation. if you want to add something to your class, use accessor methods (get and set). Cheers, Catalin "Sparky Kopetzky" <sparkyk@blackmesa-isp.net> wrote in message news:000a01c32227$a7408c00$82dbfcd0@blackmesaisp.net... Hi, again!! I'm building a class that has an associative array the I want to reveal to the outside called $lot. Code that uses the class should be able to put data into the array. When the user has finished filling the array, they should be able to send the array back to the class for further processing. Can I get away with this: var $lot; // $lot initialized by constructor function GetEmptyLot() { return $this->lot; } function UseLot($lot) { // processing goes here } or do I use this instead $mylot = new lot; $mylot->lot['something'] = value; $mylot->lot['something'] = value; $mylot->lot['something'] = value; $mylot->lot['something'] = value; mylot->UseLot(); // where $lot is still inside $mylot Looked throught the php manual and could not find a instance of this type of code. Help!! Robin E. Kopetzky Black Mesa Computers/Internet Services www.blackmesa-isp.net

« previous php.general (#148874) next »