Problem with Associative Array in Class

From: Date: Mon, 13 Nov 2000 13:38:42 +0000
Subject: Problem with Associative Array in Class
Groups: php.general 
Request: Send a blank email to php-general+get-24957@lists.php.net to get a copy of this message
A question: I placed an associated array in a class and during when adding new elements to the array nothing happened. The initial element kept being reset with the new key and value. Once I moved it outside the class everything was fine. Anyone have any ideas? Here is the code: // class for managing data parsed class Spif { var $spifValues = array(); function setVar($what, $value) { $this->$spifValues[$what] = $value; } function getVar($what) { return $this->$spifValues[$what]; } function printVars() { echo count($this->$spifValues); } } <-snip-> Calls the the class happened as sush: $newSpif->SetVar('info_checksum', $data); Every time print vars was called at the end the size came back a 1.

« previous php.general (#24957) next »