Re: 5.4 regression: non-existent sub-sub keys now have values

From: Date: Wed, 23 Nov 2011 14:14:09 +0000
Subject: Re: 5.4 regression: non-existent sub-sub keys now have values
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-56504@lists.php.net to get a copy of this message
Hi Stas: > It's actually very simple. Take variable $a which is a string > ("foo"). Now it you do $a[0] that would produce first letter - "f". > Now here's a tricky part - if you do $a['blah'] it would convert > 'blah' to number, get 0 and return the same letter "f". To me, this is the bug. $a['blah'] does not exist. An undefined index 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"; But that second one echos out "f". This is a huge WTF. Thanks, --Dan -- T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y data intensive web and database programming http://www.AnalysisAndSolutions.com/ 4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409

« previous php.internals (#56504) next »