Re: Arrays within classes

From: Date: Thu, 11 Apr 2002 13:56:30 +0000
Subject: Re: Arrays within classes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-92570@lists.php.net to get a copy of this message
On Friday, April 5, 2002, at 03:00 PM, Brian McLaughlin wrote:
My problem is that when I assign an empty array to a variable, I get different results depending on whether that variable is in an object or not. In the case of assigning $a=array(); outside of an object, each element of the array is empty (as I expected). But when assigning $this->$words=array(); results in $this->$words["Amy"] (or any other element for that matter) already being assigned an array. And if I look at the elements of those arrays, they are also initialized to arrays. I don't know how deep it goes.
Brian, Sorry to take so long to get back to you about this -- my inbox is very cluttered. The only thing I can think of is to ask you if you are sure you need the second buck in "$this->$words = array()" -- perhaps you have a reason for using a variable as the name of the class variable, but I would probably write it as "$this->words = array()". If that is not the source of your problem, re-post to the list and perhaps Lars Torben or one of the gurus will spot this idiosyncracy and have an explanation. or if you have already solved it, can you let me know what it was? I'm starting to do some object stuff in PHP and need to know about strange behavior like this. Regards, Erik ---- Erik Price Web Developer Temp Media Lab, H.H. Brown pricee@hhbrown.com

« previous php.general (#92570) next »