Re: Illegal use of string offset

From: Date: Tue, 27 Apr 2004 11:34:47 +0000
Subject: Re: Illegal use of string offset
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-9584@lists.php.net to get a copy of this message
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 :-)
I think we should make [] as string offset an E_STRICT or even E_ERROR because it confuses far too many people especially since we generally
E_ERROR would be a big BC break I guess. E_STRICT sounds fine to me. - Chris

« previous php.internals (#9584) next »