Bug #1304: Assignment to members of object in an array of objects
| From: | maarnold at gte dot net | Date: | Thu, 08 Apr 1999 05:32:40 +0000 |
| Subject: | Bug #1304: Assignment to members of object in an array of objects | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-4983@lists.php.net to get a copy of this message | ||
From: maarnold@gte.net
Operating system: linux
PHP version: 3.0.5
PHP Bug Type: Parser error
Bug description: Assignment to members of object in an array of objects
I've tried a work around to bug #1182, but I am getting flaky results.
The situation is...
/*
* Code snippet #1
*/
class DbFldC
{
var Name;
var Label;
}
class DbTblC
{
var Fields;
}
$DbFld = new DbFldC;
$DbFld->Name = "id";
$DbTbl = new DbTblC;
$DbTbl->Fields[] = $DbFld;
Bug 1182 says that...
$DbTbl->Fields[ 0 ]->Label = "Sequence No";
...yields a parser error, which is true;
My work around is...
/*
* Code snippet #2
*/
$TmpFld = $DbTbl->Fields[ 0 ];
$TmpFld->Label = "Sequence No.";
Unfortunately, this doesn't always work. Sometimes the assignment "sticks" and
sometimes it doesn't. Does $TmpFld reference the original object to which it was assigned, or
does the assignment make a copy of the original object (to which $TmpFld not points)? Sometimes it
does, and sometimes it doesn't.
Let's say the Code snippet #1 and #2 have been executed. Then the following code is executed...
printf( "Name is %s. Label is %s.<BR>\n", $TmpFld->Name, $TmpFld->Label );
$TmpFld2 = $DbTbl->Fields[ 0 ];
printf( "Name is %s. Label is %s.<BR>\n", $TmpFld2->Name, $TmpFld2->Label );
...This yields the following output...
Name is id. Label is Sequence No.
Name is id. Label is
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net