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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 13:01:32 2024 UTC