|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1304 Assignment to members of object in an array of objects
Submitted: 1999-04-08 01:32 UTC Modified: 1999-06-20 20:30 UTC
From: maarnold at gte dot net Assigned:
Status: Closed Package: Parser error
PHP Version: 3.0.5 OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
44 - 32 = ?
Subscribe to this entry?

 [1999-04-08 01:32 UTC] maarnold at gte dot net
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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [1999-06-20 20:30 UTC] jim at cvs dot php dot net
Assignment makes a copy, not a reference (and
the original problem will be solved in PHP4).
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Nov 28 23:01:27 2023 UTC