|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #843 Cannot assign to object instance variable within an array of objects
Submitted: 1998-10-10 16:07 UTC Modified: 1998-10-12 11:59 UTC
From: palle at simonsens dot com Assigned:
Status: Closed Package: Parser error
PHP Version: 3.0.5 OS: Linux /Redhat
Private report: No CVE-ID: None
 [1998-10-10 16:07 UTC] palle at simonsens dot com
I have checked in the mailings lists and have found no way to do this, only one other user (css - sutherland) complaining about the same.

Here goes:

How do you assign to an object instance variable within an array?

// This is somewhat perverted w.r.t. my orig. code
// ... lot of class definitions, db queries and such ...
// This is from within a class function. The class has a "has-part" rel. to CartItem 
$this->items[i] = new CartItem();
$this->items[1]->amnt++; // Parser error
$item = $this->items[1];
$item->amnt++;  	// No parser error, but assignments are by value, so nothing
 		// happens to "items[1]

I have also tried fiddling with the {} syntax of $$ variables, but to no avail - help!


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [1998-10-12 11:59 UTC] zeev
It cannot be done in PHP 3.0.  Search the mailing list for
letters from me, discussing limitations of the objects
implementation in PHP 3.0.

We will try to address this in PHP 3.1
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Dec 05 16:01:29 2023 UTC