On Sun, 2011-12-04 at 00:08 +0800, Alan Knowles wrote: > This patch is a start. > https://bugs.php.net/patch-display.php?bug_id=60362&patch=first_effort_to_fix_this&revision=latest > > It's been quite a while since I hacked on the engine, so the patch only > works reasonably well.. (see the FIXME on the tests at the bottom of the > patch.) > > The patch changes the following: > * $s = "string"; $s['offset'] -- produces a warning (and returns an > empty string) > * $s = "string"; $s['1'] -- works as before.. > * $s = "string"; $s[true] $s[false] $s[0.1] -- give a notice (cast it > to an int if you want to get rid of the notice) - however work as before. > * changes the warning on invalid indexes to say "Uninitialized or > invalid" rather than just "Uninitialized" > * fixes most of the related tests
I think it's bad to add another set of casting rules to the language. I'd prefer splitting the string offset operator from array offset. $a = [0,1,2,3]; $s = "string"; $a{0}; // wrong $s{0}; // ok $a[0]; // ok $s[0]; // wrong Yes, something like this has been discussed before, back and forth and doing this is too late for 5.4, but let's look to 5.5. johannes -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php