From: Operating system: Ubuntu Linux 10.04 x64 PHP version: 5.3.3 Package: Variables related Bug Type: Feature/Change Request Bug description:string variable array acces with string index should emit E_NOTICE
Description: ------------ It sometimes happens that you accidentially acces a string via array access and be so unfortunate to have used a string index :-) Since I see no point in using stingindexes for accessing strings via array access at any time, I propose to issue an E_NOTICE when a string index is cast to integer for array access (on strings), if that is possible. Test script: --------------- <?php $stringValue = 'foobar'; echo $stringValue['baz']; // echoes 'f' since 'baz' is cast to int 0 echo $stringValue['3baz']; // echoes 'b' since the first character of the index string is 3, thus the index string is cast to int 3 echo $stringValue['ba3z']; // echoes 'f' since 'ba3z' is cast to int 0 ?> Expected result: ---------------- f b f -- Edit bug report at http://bugs.php.net/bug.php?id=52868&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52868&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52868&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52868&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52868&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52868&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52868&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52868&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52868&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52868&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52868&r=support Expected behavior: http://bugs.php.net/fix.php?id=52868&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52868&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52868&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52868&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52868&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52868&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52868&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52868&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52868&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52868&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52868&r=mysqlcfg
