Edit report at https://bugs.php.net/bug.php?id=63623&edit=1
ID: 63623 Updated by: [email protected] Reported by: reayn3 at gmail dot com Summary: unexpected behaviour of array when referenced from within double apostrophe -Status: Open +Status: Not a bug Type: Bug Package: Arrays related Operating System: Xubuntu Linux 3.0.0-12-generic PHP Version: Irrelevant Block user comment: N Private report: N New Comment: You need to use the complex syntax: http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex â "{$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. Previous Comments: ------------------------------------------------------------------------ [2012-11-27 12:22:57] reayn3 at gmail dot com Description: ------------ --- >From manual page: http://www.php.net/language.types.array --- 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: --------------- <?php Class T { private $a = array("c","d") ; public function f() { return "$this->a[1]" ; } } $c = new T() ; echo $c->f() ; Expected result: ---------------- d Actual result: -------------- Array[1] ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63623&edit=1
