Grrr what a newbie mistake (about the scope I mean)! I guess I assumed that in a class, the $this-> was redundant for a method (it is in J++ which is where I learned my OOP). So all my variables in the main class were 'global' to methods in the class. My second bit of confusion is that I've made classes before where I do this:
class myclass { var $five = 5; ... } And it works fine, so you can see how the subtle difference (no var keyword basically) could lend to confusion. I still don't fully agree with the fact that I can't initialize the array key/value like that. It seems to me logical that it should work after I declared the array already. class myclass { var $myPacket = array(); $myPacket["blah"] = "asdfasdfasdf"; ... } Thanks guys! > -----Original Message----- > From: John W. Holmes [mailto:[EMAIL PROTECTED] > Sent: Wednesday, December 10, 2003 6:54 PM > To: Daevid Vincent > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP] Help with associative array in a PHP > class. Not working as I'd expect it to?! > > Daevid Vincent wrote: > > > myPacket: > > ------ > > > > How come I don't get ANY array under "myPacket:"? > [snip] > > function printMyVars() > > { > > echo "myPacket:\n"; > > print_r($myPacket); > > } > > Two words: Variable Scope. :) > > $myPacket is local to the function and empty. > > -- > ---John Holmes... > > Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ > > php|architect: The Magazine for PHP Professionals - www.phparch.com > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php