php.net |  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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: palle at simonsens dot com
New email:
PHP Version: OS:

 

 [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!

Patches

Pull Requests

History

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 08 03:01:28 2024 UTC