php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42622 Cannot use $object->{'prop["key"]}
Submitted: 2007-09-11 10:41 UTC Modified: 2007-09-11 11:00 UTC
From: adrian dot gheorghe at gmail dot com Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.2.4 OS: Windows
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: adrian dot gheorghe at gmail dot com
New email:
PHP Version: OS:

 

 [2007-09-11 10:41 UTC] adrian dot gheorghe at gmail dot com
Description:
------------
If this is not going to be supported, it should at least be documented. I couldn't find anything related to this limitation.

Reproduce code:
---------------
<?php
class Foo
{
	public $a = 3;
	public $b = array( 'c' => 9 );
}

$bar = new Foo;
echo $bar->{'a'}; // works
echo $bar->{'b["c"]'}; // doesn't work
?>

Expected result:
----------------
Output:

3
9

Actual result:
--------------
Output:

3
Notice: Undefined property: Foo::$b["c"] in C:\www\project.local.ro\trunk\Source\public\test.php on line 11

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-11 11:00 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You want $bar->{'b'}['c'].
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 17:01:33 2025 UTC