On Tue, Apr 27, 2004 at 02:16:43PM +0200, Marcus Boerger wrote: > Hello Christian, > > Tuesday, April 27, 2004, 1:34:47 PM, you wrote: > > > Marcus Boerger wrote: > >>>[ $a = 'foo'; $a['bar'] = 42; has an even weirder behaviour: It results > >>>in the string '4oo'... ] > >> > >> That's a pretty. It is using 'bar' as a sting index to 'foo' and to do > >> this it needs to convert 'bar' to an integer. The rest is obvious. > > > So you find it obvious that 42 is cast to string and the first character > > is used as replacement? Wasn't obvious to me before I tried it :-) > > That's what i meant it confuses far too many people and doesn't even make > real sense. For example converting 42 into chr(42) and setting it would > follow the same autoconversion logic. Hence a hint of kind E_STRICT would > be very good.
I know I have no karma here, but anyway: If you want to give people a hinting they access their stuff in a wrong way *and* you want it in a consistent way: why not throw an E_STRICT (or maybe even an E_NOTICE) when accessing anything via [] that is not array? $a = null; $a['foo']; -> should give an E_STRICT (if not an E_NOTICE) $a = false; $a['foo']; -> should give an E_STRICT (if not an E_NOTICE) $a = "FOO"; $a['foo']; -> should give an E_STRICT (if not an E_NOTICE) $a = array(); $a['foo']; -> gives an E_NOTICE because of "undefined index 'foo'" $a = array('foo'=>'FOO'); $a['foo'] -> obviously okay just my few p. messju > marcus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php