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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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: Sat Dec 21 17:01:58 2024 UTC