ID: 21820
Updated by: [EMAIL PROTECTED]
Reported By: george at omniti dot com
-Status: Critical
+Status: Wont fix
Bug Type: Scripting Engine problem
PHP Version: 4.3.0
New Comment:
Stig's reply on the mailing list:
Take consistency further, and you wonder should "'a'" === "a"?
No, so why should "$foo['a']" === "$foo[a]"?
The index is already quoted, it's inside the string.
The syntax we're talking about here is supposed to be
straightforward and simple, and for any kind of tricks we
recommend the "{$foo['a']}" syntax. IMHO this would bloat the syntax
beyond straightforward.
--------
Thus we better keep it like it is now -> wont fix.
Previous Comments:
------------------------------------------------------------------------
[2003-02-13 13:04:39] [EMAIL PROTECTED]
I still maintain that the patch I posted is the right way
to solve the problem.
$a['b'] is the 'correct' way to access an associative array
outside of a quoted section, it should at least be allowed
inside double quotes. This encourages consisitency within
the language.
------------------------------------------------------------------------
[2003-02-13 12:52:17] [EMAIL PROTECTED]
Marking as critical. This is a serious bug as it's subtle and confuses
newbies, especially when they/we try to use autoglobals in strings.
This bug fix really needs to make it into 4.3.1
------------------------------------------------------------------------
[2003-01-22 20:28:56] george at omniti dot com
This bug appeared in 4.3.0 as a result of the lexer changes
added to ZE1 and ZE2 in november to speed up
variableinterpolation in strings.
Previous to 4.3 this was valid:
echo "$a[b]";
but
echo "$a['b']"; generated a parse error.
The bug manifests itself by turning this parse error into a
non-sensical E_NOTICE error.
The patch 'fixes' the bug by making
echo "$a['b']";
work, which has been a pending feature request and seems
nice (to me), or at least harmless.
------------------------------------------------------------------------
[2003-01-22 19:53:20] [EMAIL PROTECTED]
Anyone remember in what version of PHP this did work? :)
Correct (?) way to do this is:
<?php
$arr = array('foo' => 'bar');
print "{$arr['foo']}";
?>
Or at least I've started to use that just because of this bug.
------------------------------------------------------------------------
[2003-01-22 13:56:01] [EMAIL PROTECTED]
Point was, maybe there is a reason this was not implemented.
And btw, this is a bug as 'foo' is defined yet the error says it's
not.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/21820
--
Edit this bug report at http://bugs.php.net/?id=21820&edit=1