Re: 5.4 regression: non-existent sub-sub keys now have values
| From: | Stas Malyshev | Date: | Wed, 23 Nov 2011 18:52:18 +0000 |
| Subject: | Re: 5.4 regression: non-existent sub-sub keys now have values | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-56523@lists.php.net to get a copy of this message | ||
Hi!
On 11/23/11 6:14 AM, Daniel Convissor wrote:
To me, this is the bug. $a['blah'] does not exist. An undefined indexIf it's a bug, this bug was in PHP since forever, nothing new here.
notice should be raised. The key "blah" should not be converted to 0. The following two things should behave the same: $b = array('exists' => 'foo'); echo $b['blah'] . "\n"; $a = 'foo'; echo $a['blah'] . "\n";No they should not. First is array access, second is string offset access, totally different ops. That's like saying + on arrays should calculate the sum of all array elements because + on numbers calculates the sum. Operators have different meanings for different types, it has always been so in all languages. One could argue that string access with non-string should produce a notice, but probably if we added that a lot of people would come out to complain we broke their perfectly working code ;) -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227