php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6489 Class array variable members not interpreted correctly within string
Submitted: 2000-09-01 13:56 UTC Modified: 2000-09-03 04:49 UTC
From: nathan at cjhunter dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.1pl2 OS: 2.0.36
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: nathan at cjhunter dot com
New email:
PHP Version: OS:

 

 [2000-09-01 13:56 UTC] nathan at cjhunter dot com
When accessing a class array variable member from within a double quoted string it is not interpreted correctly. This is certainly not a critical bug but it would "user friendly" to the developere implement such a thing.  

Example..

<?
class a {
  var $var = array("key" => "value");
}

$inst = a();

echo "$a->var[key]";
?>

Gives us 'Array[key]' instead of what I would expect, which would be 'value'.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-09-03 04:49 UTC] stas@php.net
You should use one of the following:

echo $a->var["key"]

or

echo "{$a->var[key]}"

BTW, the script you gave cannot work because it should be "new a();" and your variable is named "inst" not "a".
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sat Oct 10 16:00:02 2026 UTC