|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-01-22 09:19 UTC] george at omniti dot com
I don't think this is a bug, but someone sent it to me via
email, so I'm proxy-submitting:
Hello George-
I stumbled upon a serious bug in the string parser and it
goes something like this:
$arr = array('foo' => 'bar');
print "$arr['foo']";
This used to provide a parse error but now instead we get
this one of level E_NOTICE:
Notice: Undefined index: 'foo' in /tmp/a.php on line 4
/tmp/a.php(4) : Notice - Undefined index: 'foo'
This is a serious problem as it moved an error from
parse to E_NOTICE, fails silently as most have error
reporting turned down, shows a misleading error as foo
is defined, and breaks BC.
Tested latest 4_3 HEAD (4.3.1-dev). I would try php5
but I get segfault when trying to compile/use it :)
Have a nice day,
Philip Olson
cc: derick
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 05:00:01 2025 UTC |
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.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.