|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17781 Array assignment through method
Submitted: 2002-06-16 08:59 UTC Modified: 2002-06-16 11:08 UTC
From: Oliver dot Siegmar at xams dot org Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 4.1.2 OS: Linux
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: Oliver dot Siegmar at xams dot org
New email:
PHP Version: OS:


 [2002-06-16 08:59 UTC] Oliver dot Siegmar at xams dot org
class testclass {
    function assign($var, $value) {
        $this->$var = $value;

$testobj = new testclass();

$testobj->testvar = 20;
$testobj->assign("testvar", 30);
echo $testobj->testvar; // Result = 30 - very good!

$testobj->testarray["dim1"]["dim2"] = 20;
$testobj->assign("testarray[dim1][dim2]", 30);
echo $testobj->testarray["dim1"]["dim2"]; // Result = 20 - bad (should be 30)!


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-16 09:07 UTC]
This is just not possible. You can't specify a value of an array using variable variables.
 [2002-06-16 11:08 UTC]
... but you could use eval() ...
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Jun 05 00:03:38 2023 UTC