|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63623 unexpected behaviour of array when referenced from within double apostrophe
Submitted: 2012-11-27 12:22 UTC Modified: 2012-11-27 12:27 UTC
From: reayn3 at gmail dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: Irrelevant OS: Xubuntu Linux 3.0.0-12-generic
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: reayn3 at gmail dot com
New email:
PHP Version: OS:


 [2012-11-27 12:22 UTC] reayn3 at gmail dot com
From manual page:
While using an echo command with a double apostrophe argument that includes an array variable, the name of the Array object is outputted rather than the actual value for the array item

Test script:

Class T {
        private $a = array("c","d") ;

        public function f() {
                return "$this->a[1]" ;

$c = new T() ;
echo $c->f() ;

Expected result:

Actual result:


fix_for_array_output (last revision 2012-11-27 12:23 UTC by reayn3 at gmail dot com)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-27 12:27 UTC]
-Status: Open +Status: Not a bug
 [2012-11-27 12:27 UTC]
You need to use the complex syntax: — "{$this->a[1]}" will work as expected.

As the manual says about the simple syntax: "Similarly, an array index or an object property can be parsed" — you can't have both an object property and an array index.

Closing NaB.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Jan 22 16:01:24 2021 UTC